-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patherrors.py
150 lines (96 loc) · 3.79 KB
/
errors.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from flake8_plugin_utils import Error
class IncorrectFixtureParenthesesStyle(Error):
code = 'PT001'
message = 'use @pytest.fixture{expected_parens} over @pytest.fixture{actual_parens}'
class FixturePositionalArgs(Error):
code = 'PT002'
message = (
"configuration for fixture '{name}' specified via positional args, use kwargs"
)
class ExtraneousScopeFunction(Error):
code = 'PT003'
message = "scope='function' is implied in @pytest.fixture()"
class MissingFixtureNameUnderscore(Error):
code = 'PT004'
message = "fixture '{name}' does not return anything, add leading underscore"
class IncorrectFixtureNameUnderscore(Error):
code = 'PT005'
message = "fixture '{name}' returns a value, remove leading underscore"
class ParametrizeNamesWrongType(Error):
code = 'PT006'
message = 'wrong name(s) type in @pytest.mark.parametrize, expected {expected_type}'
class ParametrizeValuesWrongType(Error):
code = 'PT007'
message = 'wrong values type in @pytest.mark.parametrize, expected {expected_type}'
class PatchWithLambda(Error):
code = 'PT008'
message = 'use return_value= instead of patching with lambda'
class UnittestAssertion(Error):
code = 'PT009'
message = "use a regular assert instead of unittest-style '{assertion}'"
class RaisesWithoutException(Error):
code = 'PT010'
message = 'set the expected exception in pytest.raises()'
class RaisesTooBroad(Error):
code = 'PT011'
message = (
'pytest.raises({exception}) is too broad,'
' set the match parameter or use a more specific exception'
)
class RaisesWithMultipleStatements(Error):
code = 'PT012'
message = 'pytest.raises() block should contain a single simple statement'
class IncorrectPytestImport(Error):
code = 'PT013'
message = "found incorrect import of pytest, use simple 'import pytest' instead"
class DuplicateParametrizeTestCases(Error):
code = 'PT014'
message = 'found duplicate test cases {indexes} in @pytest.mark.parametrize'
class AssertAlwaysFalse(Error):
code = 'PT015'
message = 'assertion always fails, replace with pytest.fail()'
class FailWithoutMessage(Error):
code = 'PT016'
message = 'no message passed to pytest.fail()'
class AssertInExcept(Error):
code = 'PT017'
message = (
'found assertion on exception {name} in except block,'
' use pytest.raises() instead'
)
class CompositeAssertion(Error):
code = 'PT018'
message = 'assertion should be broken down into multiple parts'
class FixtureParamWithoutValue(Error):
code = 'PT019'
message = (
'fixture {name} without value is injected as parameter,'
' use @pytest.mark.usefixtures instead'
)
class DeprecatedYieldFixture(Error):
code = 'PT020'
message = '@pytest.yield_fixture is deprecated, use @pytest.fixture'
class FixtureFinalizerCallback(Error):
code = 'PT021'
message = 'use yield instead of request.addfinalizer'
class UselessYieldFixture(Error):
code = 'PT022'
message = 'no teardown in fixture {name}, use return instead of yield'
class IncorrectMarkParenthesesStyle(Error):
code = 'PT023'
message = (
'use @pytest.mark.{mark_name}{expected_parens}'
' over @pytest.mark.{mark_name}{actual_parens}'
)
class UnnecessaryAsyncioMarkOnFixture(Error):
code = 'PT024'
message = 'pytest.mark.asyncio is unnecessary for fixtures'
class ErroneousUseFixturesOnFixture(Error):
code = 'PT025'
message = 'pytest.mark.usefixtures has no effect on fixtures'
class UseFixturesWithoutParameters(Error):
code = 'PT026'
message = 'useless pytest.mark.usefixtures without parameters'
class UnittestRaisesAssertion(Error):
code = 'PT027'
message = "use pytest.raises() instead of unittest-style '{assertion}'"