8000 Inject a test that checks the mypy exit status by dmtucker · Pull Request #79 · realpython/pytest-mypy · GitHub
[go: up one dir, main page]

Skip to content

Inject a test that checks the mypy exit status #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use pytest-style names in the tests
  • Loading branch information
dmtucker committed Mar 1, 2020
commit 32a27f62cb1d44ecdc1345b65c9a1c24cc095268
16 changes: 8 additions & 8 deletions tests/test_pytest_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ def xdist_args(request):
return ['-n', 'auto'] if request.param else []


@pytest.mark.parametrize('test_count', [1, 2])
def test_mypy_success(testdir, test_count, xdist_args):
@pytest.mark.parametrize('pyfile_count', [1, 2])
def test_mypy_success(testdir, pyfile_count, xdist_args):
"""Verify that running on a module with no type errors passes."""
testdir.makepyfile(
**{
'test_' + str(test_i): '''
def myfunc(x: int) -> int:
'pyfile_' + str(pyfile_i): '''
def pyfunc(x: int) -> int:
return x * 2
'''
for test_i in range(test_count)
for pyfile_i in range(pyfile_count)
}
)
result = testdir.runpytest_subprocess(*xdist_args)
result.assert_outcomes()
result = testdir.runpytest_subprocess('--mypy', *xdist_args)
result.assert_outcomes(passed=test_count)
result.assert_outcomes(passed=pyfile_count)
assert result.ret == 0


def test_mypy_error(testdir, xdist_args):
"""Verify that running on a module with type errors fails."""
testdir.makepyfile('''
def myfunc(x: int) -> str:
def pyfunc(x: int) -> str:
return x * 2
''')
result = testdir.runpytest_subprocess(*xdist_args)
Expand Down Expand Up @@ -178,7 +178,7 @@ def pytest_collection_modifyitems(session, config, items):
items.pop(mypy_item_i)
''')
testdir.makepyfile('''
def myfunc(x: int) -> str:
def pyfunc(x: int) -> str:
return x * 2

def test_pass():
Expand Down
0