Skip to content

Commit 4a5e0df

Browse files
committed
Create test_mypy_config_file
1 parent 5fbff02 commit 4a5e0df

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_pytest_mypy.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,36 @@ def test_mypy_ignore_missings_imports(testdir, xdist_args):
129129
assert result.ret == 0
130130

131131

132+
def test_mypy_config_file(testdir, xdist_args):
133+
"""Verify that --mypy-config-file works."""
134+
testdir.makepyfile(
135+
"""
136+
from typing import Any
137+
138+
def pyfunc(x: int) -> Any:
139+
return x * 2
140+
""",
141+
)
142+
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
143+
mypy_file_checks = 1
144+
mypy_status_check = 1
145+
mypy_checks = mypy_file_checks + mypy_status_check
146+
result.assert_outcomes(passed=mypy_checks)
147+
assert result.ret == 0
148+
mypy_config_file = testdir.makeini(
149+
"""
150+
[mypy]
151+
disallow_any_explicit = True
152+
""",
153+
)
154+
result = testdir.runpytest_subprocess(
155+
"--mypy-config-file",
156+
mypy_config_file,
157+
*xdist_args,
158+
)
159+
result.assert_outcomes(failed=mypy_checks)
160+
161+
132162
def test_mypy_marker(testdir, xdist_args):
133163
"""Verify that -m mypy only runs the mypy tests."""
134164
testdir.makepyfile(

0 commit comments

Comments
 (0)