File: test_decorators.py

package info (click to toggle)
pycallgraph 1.1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 416 kB
  • sloc: python: 1,925; makefile: 47
file content (39 lines) | stat: -rw-r--r-- 781 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pytest

import pycallgraph2
from pycallgraph2 import PyCallGraphException
from pycallgraph2.output import GephiOutput, GraphvizOutput


@pycallgraph2.decorators.trace(output=GraphvizOutput())
def print_something():
    print("hello")


@pycallgraph2.decorators.trace(output=GephiOutput())
def print_foo():
    print("foo")


@pycallgraph2.decorators.trace()
def print_bar():
    print("bar")


def test_trace_decorator_graphviz_output():
    print_something()


def test_trace_decorator_gephi_output():
    print_foo()


def test_trace_decorator_parameter():
    with pytest.raises(PyCallGraphException):
        print_bar()


if __name__ == "__main__":
    test_trace_decorator_graphviz_output()
    test_trace_decorator_gephi_output()
    test_trace_decorator_parameter()