|
| 1 | +# 3rd party |
1 | 2 | import pytest |
2 | 3 | from pytest import fixture |
3 | 4 |
|
| 5 | +# this package |
4 | 6 | from sphinx_autofixture import is_fixture |
5 | 7 |
|
6 | 8 |
|
@@ -49,37 +51,48 @@ def pytest_call_scoped(): |
49 | 51 | """ |
50 | 52 |
|
51 | 53 |
|
52 | | -@pytest.mark.parametrize("func, scope", [ |
53 | | - pytest.param(name, "function", id="name"), |
54 | | - pytest.param(call, "function", id="call"), |
55 | | - pytest.param(call_scoped, "module", id="call_scoped"), |
56 | | - pytest.param(pytest_attribute, "function", id="pytest_attribute"), |
57 | | - pytest.param(pytest_call, "function", id="pytest_call"), |
58 | | - pytest.param(pytest_call_scoped, "module", id="pytest_call_scoped"), |
59 | | - ]) |
| 54 | +@pytest.mark.parametrize( |
| 55 | + "func, scope", |
| 56 | + [ |
| 57 | + pytest.param(name, "function", id="name"), |
| 58 | + pytest.param(call, "function", id="call"), |
| 59 | + pytest.param(call_scoped, "module", id="call_scoped"), |
| 60 | + pytest.param(pytest_attribute, "function", id="pytest_attribute"), |
| 61 | + pytest.param(pytest_call, "function", id="pytest_call"), |
| 62 | + pytest.param(pytest_call_scoped, "module", id="pytest_call_scoped"), |
| 63 | + ] |
| 64 | + ) |
60 | 65 | def test_is_fixture(func, scope): |
61 | 66 | assert is_fixture(func) == (True, scope) |
62 | 67 |
|
63 | 68 |
|
64 | | -def function(): pass |
| 69 | +def function(): |
| 70 | + pass |
65 | 71 |
|
66 | 72 |
|
67 | 73 | class Class: |
68 | 74 |
|
69 | | - def method(self): pass |
| 75 | + def method(self): |
| 76 | + pass |
70 | 77 |
|
71 | 78 |
|
72 | | -def deco(func): return func |
73 | | - |
74 | | -@deco |
75 | | -def decorated(): pass |
| 79 | +def deco(func): |
| 80 | + return func |
76 | 81 |
|
77 | 82 |
|
78 | | -@pytest.mark.parametrize("func", [ |
79 | | - pytest.param(function, id="function"), |
80 | | - pytest.param(decorated, id="decorated"), |
81 | | - pytest.param(Class.method, id="Class.method"), |
82 | | - pytest.param(Class().method, id="Class().method"), |
83 | | - ]) |
| 83 | +@deco |
| 84 | +def decorated(): |
| 85 | + pass |
| 86 | + |
| 87 | + |
| 88 | +@pytest.mark.parametrize( |
| 89 | + "func", |
| 90 | + [ |
| 91 | + pytest.param(function, id="function"), |
| 92 | + pytest.param(decorated, id="decorated"), |
| 93 | + pytest.param(Class.method, id="Class.method"), |
| 94 | + pytest.param(Class().method, id="Class().method"), |
| 95 | + ] |
| 96 | + ) |
84 | 97 | def test_isnt_fixture(func): |
85 | 98 | assert is_fixture(func) == (False, None) |
0 commit comments