Skip to content

Commit dcea166

Browse files
committed
Speed up tests by combining them
1 parent 168b4b8 commit dcea166

File tree

1 file changed

+43
-55
lines changed

1 file changed

+43
-55
lines changed

test-data/unit/cmdline.pyproject.test

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -138,89 +138,77 @@ description = "Factory ⸻ A code generator 🏭"
138138
# cmd: mypy
139139
[file pyproject.toml]
140140
\[tool.mypy]
141+
# We combine multiple tests in a single one here, because these tests are slow.
141142
files = """
142143
a.py,
143144
b.py,
144145
"""
145-
[file a.py]
146-
x: str = 'x' # ok
147-
[file b.py]
148-
y: int = 'y' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
149-
[file c.py]
150-
# This should not trigger any errors, because it is not included:
151-
z: int = 'z'
152-
[out]
153-
154-
[case testPyprojectAlwaysTrueTrailingComma]
155-
# cmd: mypy .
156-
[file pyproject.toml]
157-
\[tool.mypy]
158146
always_true = """
159-
FLAG_A,
160-
FLAG_B,
147+
FLAG_A1,
148+
FLAG_B1,
161149
"""
162-
[file a.py]
163-
FLAG_A = False
164-
FLAG_B = False
165-
if not FLAG_A: # unreachable
166-
x: int = 'x'
167-
if not FLAG_B: # unreachable
168-
y: int = 'y'
169-
170-
[case testPyprojectAlwaysFalseTrailingComma]
171-
# cmd: mypy .
172-
[file pyproject.toml]
173-
\[tool.mypy]
174150
always_false = """
175-
FLAG_A,
176-
FLAG_B,
151+
FLAG_A2,
152+
FLAG_B2,
177153
"""
178154
[file a.py]
179-
FLAG_A = True
180-
FLAG_B = True
181-
if FLAG_A: # unreachable
155+
x: str = 'x' # ok'
156+
157+
# --always-true
158+
FLAG_A1 = False
159+
FLAG_B1 = False
160+
if not FLAG_A1: # unreachable
182161
x: int = 'x'
183-
if FLAG_B: # unreachable
162+
if not FLAG_B1: # unreachable
184163
y: int = 'y'
185164

186-
[case testPyprojectEnableErrorCodeTrailingComma]
187-
# cmd: mypy .
188-
[file pyproject.toml]
189-
\[tool.mypy]
190-
enable_error_code = """
191-
redundant-expr,
192-
ignore-without-code,
193-
"""
194-
[file a.py]
195-
1 + 'a' # type: ignore # E: "type: ignore" comment without error code (consider "type: ignore[operator]" instead)
196-
197-
[case testPyprojectDisableErrorCodeTrailingComma]
198-
# cmd: mypy .
199-
[file pyproject.toml]
200-
\[tool.mypy]
201-
disable_error_code = """
202-
operator,
203-
import,
204-
"""
205-
[file a.py]
206-
1 + 'a'
165+
# --always-false
166+
FLAG_A2 = True
167+
FLAG_B2 = True
168+
if FLAG_A2: # unreachable
169+
x: int = 'x'
170+
if FLAG_B2: # unreachable
171+
y: int = 'y'
172+
[file b.py]
173+
y: int = 'y' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
174+
[file c.py]
175+
# This should not trigger any errors, because it is not included:
176+
z: int = 'z'
177+
[out]
207178

208179
[case testPyprojectModulesTrailingComma]
209180
# cmd: mypy
210181
[file pyproject.toml]
211182
\[tool.mypy]
183+
# We combine multiple tests in a single one here, because these tests are slow.
212184
modules = """
213185
a,
214186
b,
215187
"""
188+
disable_error_code = """
189+
operator,
190+
import,
191+
"""
192+
enable_error_code = """
193+
redundant-expr,
194+
ignore-without-code,
195+
"""
216196
[file a.py]
217197
x: str = 'x' # ok
198+
199+
# --enable-error-code
200+
a: int = 'a' # type: ignore
201+
202+
# --disable-error-code
203+
'a' + 1
218204
[file b.py]
219-
y: int = 'y' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
205+
y: int = 'y'
220206
[file c.py]
221207
# This should not trigger any errors, because it is not included:
222208
z: int = 'z'
223209
[out]
210+
b.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int")
211+
a.py:4: error: "type: ignore" comment without error code (consider "type: ignore[assignment]" instead)
224212

225213
[case testPyprojectPackagesTrailingComma]
226214
# cmd: mypy

0 commit comments

Comments
 (0)