-
Notifications
You must be signed in to change notification settings - Fork 33
0.8.1: pytest is failing because cannot find module named is_always_missing
#126
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
Comments
is_always_missing
The problem appears to be that the quotes have changed... We're looking for single quotes:
But we're encountering double quotes:
What version of |
0.910. |
The quotes were changed in 0.900: python/mypy@0e7b867#diff-ad419c230fdadf186f17fbee963b2c0431a94d935d0204fe1297d336e8fe99e6L58-R65 Strange that the tests aren't reliably reproducing this issue for me 🤔 |
Heh... Oh ya, because this was fixed (in #121) already 😅 Are you working with a clone or an sdist? |
I think that we can postpone for few days this issue. |
OK I have updated mypy to 0.931. However pytest still is failing in multiple units 😞 + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-mypy-0.8.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-mypy-0.8.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1, configfile: tox.ini, testpaths: tests
plugins: mypy-0.8.1, timeout-2.0.2
collected 50 items
tests/test_pytest_mypy.py FF....F..F..F..F..F..F..F..F..F..FF....F..F..FFF.. [100%]
================================================================================= FAILURES =================================================================================
________________________________________________________________________ test_mypy_success[True-1] _________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_success0')>, pyfile_count = 1, xdist_args = ['-n', 'auto']
@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(
**{
"pyfile_{0}".format(
pyfile_i,
): """
def pyfunc(x: int) -> int:
return x * 2
"""
for pyfile_i in range(pyfile_count)
},
)
result = testdir.runpytest_subprocess(*xdist_args)
> result.assert_outcomes()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_success0/runpytest-0 -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_success0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_success0
________________________________________________________________________ test_mypy_success[True-2] _________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_success1')>, pyfile_count = 2, xdist_args = ['-n', 'auto']
@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(
**{
"pyfile_{0}".format(
pyfile_i,
): """
def pyfunc(x: int) -> int:
return x * 2
"""
for pyfile_i in range(pyfile_count)
},
)
result = testdir.runpytest_subprocess(*xdist_args)
> result.assert_outcomes()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_success1/runpytest-0 -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_success1
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_success1
___________________________________________________________________________ test_mypy_pyi[True] ____________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_pyi0')>, xdist_args = ['-n', 'auto']
def test_mypy_pyi(testdir, xdist_args):
"""
Verify that a .py file will be skipped if
a .pyi file exists with the same filename.
"""
# The incorrect signature below should be ignored
# as the .pyi file takes priority
testdir.makepyfile(
pyfile="""
def pyfunc(x: int) -> str:
return x * 2
""",
)
testdir.makefile(
".pyi",
pyfile="""
def pyfunc(x: int) -> int: ...
""",
)
result = testdir.runpytest_subprocess(*xdist_args)
> result.assert_outcomes()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:70:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_pyi0/runpytest-0 -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_pyi0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_pyi0
__________________________________________________________________________ test_mypy_error[True] ___________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_error0')>, xdist_args = ['-n', 'auto']
def test_mypy_error(testdir, xdist_args):
"""Verify that running on a module with type errors fails."""
testdir.makepyfile(
"""
def pyfunc(x: int) -> str:
return x * 2
""",
)
result = testdir.runpytest_subprocess(*xdist_args)
> result.assert_outcomes()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:88:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_error0/runpytest-0 -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_error0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_error0
_________________________________________________________________ test_mypy_ignore_missings_imports[True] __________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_ignore_missings_imports0')>, xdist_args = ['-n', 'auto']
def test_mypy_ignore_missings_imports(testdir, xdist_args):
"""
Verify that --mypy-ignore-missing-imports
causes mypy to ignore missing imports.
"""
module_name = "is_always_missing"
testdir.makepyfile(
"""
try:
import {module_name}
except ImportError:
pass
""".format(
module_name=module_name,
),
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
mypy_file_checks = 1
mypy_status_check = 1
mypy_checks = mypy_file_checks + mypy_status_check
> result.assert_outcomes(failed=mypy_checks)
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:118:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_ignore_missings_imports0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_ignore_missings_imports0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_ignore_missings_imports0
__________________________________________________________________________ test_mypy_marker[True] __________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_marker0')>, xdist_args = ['-n', 'auto']
def test_mypy_marker(testdir, xdist_args):
"""Verify that -m mypy only runs the mypy tests."""
testdir.makepyfile(
"""
def test_fails():
assert False
""",
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
test_count = 1
mypy_file_checks = 1
mypy_status_check = 1
mypy_checks = mypy_file_checks + mypy_status_check
> result.assert_outcomes(failed=test_count, passed=mypy_checks)
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:145:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_marker0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_marker0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_marker0
________________________________________________________________________ test_non_mypy_error[True] _________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_non_mypy_error0')>, xdist_args = ['-n', 'auto']
def test_non_mypy_error(testdir, xdist_args):
"""Verify that non-MypyError exceptions are passed through the plugin."""
message = "This is not a MypyError."
testdir.makepyfile(
conftest="""
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('mypy')
class PatchedMypyFileItem(plugin.MypyFileItem):
def runtest(self):
raise Exception('{message}')
plugin.MypyFileItem = PatchedMypyFileItem
""".format(
message=message,
),
)
result = testdir.runpytest_subprocess(*xdist_args)
> result.assert_outcomes()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_non_mypy_error0/runpytest-0 -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_non_mypy_error0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_non_mypy_error0
__________________________________________________________________________ test_mypy_stderr[True] __________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_stderr0')>, xdist_args = ['-n', 'auto']
def test_mypy_stderr(testdir, xdist_args):
"""Verify that stderr from mypy is printed."""
stderr = "This is stderr from mypy."
testdir.makepyfile(
conftest="""
import mypy.api
def _patched_run(*args, **kwargs):
return '', '{stderr}', 1
mypy.api.run = _patched_run
""".format(
stderr=stderr,
),
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
> result.stdout.fnmatch_lines([stderr])
E Failed: remains unmatched: 'This is stderr from mypy.'
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:198: Failed
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_stderr0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_stderr0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_stderr0
_____________________________________________________________________ test_mypy_unmatched_stdout[True] _____________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_unmatched_stdout0')>, xdist_args = ['-n', 'auto']
def test_mypy_unmatched_stdout(testdir, xdist_args):
"""Verify that unexpected output on stdout from mypy is printed."""
stdout = "This is unexpected output on stdout from mypy."
testdir.makepyfile(
conftest="""
import mypy.api
def _patched_run(*args, **kwargs):
return '{stdout}', '', 1
mypy.api.run = _patched_run
""".format(
stdout=stdout,
),
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
> result.stdout.fnmatch_lines([stdout])
E Failed: remains unmatched: 'This is unexpected output on stdout from mypy.'
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:217: Failed
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_unmatched_stdout0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_unmatched_stdout0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_unmatched_stdout0
_________________________________________________________________________ test_api_mypy_argv[True] _________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_api_mypy_argv0')>, xdist_args = ['-n', 'auto']
def test_api_mypy_argv(testdir, xdist_args):
"""Ensure that the plugin can be configured in a conftest.py."""
testdir.makepyfile(
conftest="""
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('mypy')
plugin.mypy_argv.append('--version')
""",
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
> assert result.ret == 0
E assert <ExitCode.USAGE_ERROR: 4> == 0
E + where <ExitCode.USAGE_ERROR: 4> = <RunResult ret=ExitCode.USAGE_ERROR len(stdout.lines)=0 len(stderr.lines)=5 duration=0.33s>.ret
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:230: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_api_mypy_argv0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_api_mypy_argv0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_api_mypy_argv0
________________________________________________________________________ test_api_nodeid_name[True] ________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_api_nodeid_name0')>, xdist_args = ['-n', 'auto']
def test_api_nodeid_name(testdir, xdist_args):
"""Ensure that the plugin can be configured in a conftest.py."""
nodeid_name = "UnmistakableNodeIDName"
testdir.makepyfile(
conftest="""
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('mypy')
plugin.nodeid_name = '{}'
""".format(
nodeid_name,
),
)
result = testdir.runpytest_subprocess("--mypy", "--verbose", *xdist_args)
> result.stdout.fnmatch_lines(["*conftest.py::" + nodeid_name + "*"])
E Failed: remains unmatched: '*conftest.py::UnmistakableNodeIDName*'
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:246: Failed
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_api_nodeid_name0/runpytest-0 --mypy --verbose -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_api_nodeid_name0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_api_nodeid_name0
____________________________________________________________________ test_mypy_indirect[True-__init__] _____________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect0')>, xdist_args = ['-n', 'auto'], module_name = '__init__'
@pytest.mark.parametrize(
"module_name",
[
pytest.param(
"__init__",
marks=pytest.mark.xfail(
(3, 10) <= PYTEST_VERSION < (6, 2),
raises=AssertionError,
reason="https://github.com/pytest-dev/pytest/issues/8016",
),
),
"good",
],
)
def test_mypy_indirect(testdir, xdist_args, module_name):
"""Verify that uncollected files checked by mypy cause a failure."""
testdir.makepyfile(
bad="""
def pyfunc(x: int) -> str:
return x * 2
""",
)
pyfile = testdir.makepyfile(
**{
module_name: """
import bad
""",
},
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args, str(pyfile))
mypy_file_checks = 1
mypy_status_check = 1
> result.assert_outcomes(passed=mypy_file_checks, failed=mypy_status_check)
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:282:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect0/runpytest-0 --mypy -n auto /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect0/__init__.py
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect0
______________________________________________________________________ test_mypy_indirect[True-good] _______________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect1')>, xdist_args = ['-n', 'auto'], module_name = 'good'
@pytest.mark.parametrize(
"module_name",
[
pytest.param(
"__init__",
marks=pytest.mark.xfail(
(3, 10) <= PYTEST_VERSION < (6, 2),
raises=AssertionError,
reason="https://github.com/pytest-dev/pytest/issues/8016",
),
),
"good",
],
)
def test_mypy_indirect(testdir, xdist_args, module_name):
"""Verify that uncollected files checked by mypy cause a failure."""
testdir.makepyfile(
bad="""
def pyfunc(x: int) -> str:
return x * 2
""",
)
pyfile = testdir.makepyfile(
**{
module_name: """
import bad
""",
},
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args, str(pyfile))
mypy_file_checks = 1
mypy_status_check = 1
> result.assert_outcomes(passed=mypy_file_checks, failed=mypy_status_check)
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:282:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect1/runpytest-0 --mypy -n auto /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect1/good.py
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect1
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_indirect1
______________________________________________________________________ test_api_error_formatter[True] ______________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_api_error_formatter0')>, xdist_args = ['-n', 'auto']
def test_api_error_formatter(testdir, xdist_args):
"""Ensure that the plugin can be configured in a conftest.py."""
testdir.makepyfile(
bad="""
def pyfunc(x: int) -> str:
return x * 2
""",
)
testdir.makepyfile(
conftest="""
def custom_file_error_formatter(item, results, errors):
return '\\n'.join(
'{path}:{error}'.format(
path=item.fspath,
error=error,
)
for error in errors
)
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('mypy')
plugin.file_error_formatter = custom_file_error_formatter
""",
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
> result.stdout.fnmatch_lines(["*/bad.py:2: error: Incompatible return value*"])
E Failed: remains unmatched: '*/bad.py:2: error: Incompatible return value*'
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:311: Failed
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_api_error_formatter0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_api_error_formatter0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_api_error_formatter0
___________________________________________________________________________ test_setup_cfg[True] ___________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_setup_cfg0')>, xdist_args = ['-n', 'auto']
def test_setup_cfg(testdir, xdist_args):
"""Ensure that the plugin allows configuration with setup.cfg."""
testdir.makefile(
".cfg",
setup="""
[mypy]
disallow_untyped_defs = True
""",
)
testdir.makepyfile(
conftest="""
def pyfunc(x):
return x * 2
""",
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
> result.stdout.fnmatch_lines(["1: error: Function is missing a type annotation"])
E Failed: remains unmatched: '1: error: Function is missing a type annotation'
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:331: Failed
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_setup_cfg0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_setup_cfg0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_setup_cfg0
________________________________________________________________________ test_looponfail[__init__] _________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_looponfail0')>, module_name = '__init__'
@pytest.mark.parametrize("module_name", ["__init__", "test_demo"])
def test_looponfail(testdir, module_name):
"""Ensure that the plugin works with --looponfail."""
pass_source = textwrap.dedent(
"""\
def pyfunc(x: int) -> int:
return x * 2
""",
)
fail_source = textwrap.dedent(
"""\
def pyfunc(x: int) -> str:
return x * 2
""",
)
pyfile = testdir.makepyfile(**{module_name: fail_source})
looponfailroot = testdir.mkdir("looponfailroot")
looponfailroot_pyfile = looponfailroot.join(pyfile.basename)
pyfile.move(looponfailroot_pyfile)
pyfile = looponfailroot_pyfile
testdir.makeini(
textwrap.dedent(
"""\
[pytest]
looponfailroots = {looponfailroots}
""".format(
looponfailroots=looponfailroot,
),
),
)
child = testdir.spawn_pytest(
"--mypy --looponfail " + str(pyfile),
expect_timeout=30.0,
)
num_tests = 2
if module_name == "__init__" and (3, 10) <= PYTEST_VERSION < (6, 2):
# https://github.com/pytest-dev/pytest/issues/8016
# Pytest had a bug where it assumed only a Package would have a basename of
# __init__.py. In this test, Pytest mistakes MypyFile for a Package and
# returns after collecting only one object (the MypyFileItem).
num_tests = 1
def _expect_session():
child.expect("==== test session starts ====")
def _expect_failure():
_expect_session()
child.expect("==== FAILURES ====")
child.expect(pyfile.basename + " ____")
child.expect("2: error: Incompatible return value")
# if num_tests == 2:
# # These only show with mypy>=0.730:
# child.expect("==== mypy ====")
# child.expect("Found 1 error in 1 file (checked 1 source file)")
child.expect(str(num_tests) + " failed")
child.expect("#### LOOPONFAILING ####")
_expect_waiting()
def _expect_waiting():
child.expect("#### waiting for changes ####")
child.expect("Watching")
def _fix():
pyfile.write(pass_source)
_expect_changed()
_expect_success()
def _expect_changed():
child.expect("MODIFIED " + str(pyfile))
def _expect_success():
for _ in range(2):
_expect_session()
# if num_tests == 2:
# # These only show with mypy>=0.730:
# child.expect("==== mypy ====")
# child.expect("Success: no issues found in 1 source file")
try:
child.expect(str(num_tests) + " passed")
except pexpect.exceptions.TIMEOUT:
if module_name == "__init__" and (6, 0) <= PYTEST_VERSION < (6, 2):
# MypyItems hit the __init__.py bug too when --looponfail
# re-collects them after the failing file is modified.
# Unlike MypyFile, MypyItem is not a Collector, so this used
# to cause an AttributeError until a workaround was added
# (MypyItem.collect was defined to yield itself).
# Mypy probably noticed the __init__.py problem during the
# development of Pytest 6.0, but the error was addressed
# with an isinstance assertion, which broke the workaround.
# Here, we hit that assertion:
child.expect("AssertionError")
child.expect("1 error")
pytest.xfail("https://github.com/pytest-dev/pytest/issues/8016")
raise
_expect_waiting()
def _break():
pyfile.write(fail_source)
_expect_changed()
_expect_failure()
> _expect_failure()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:439:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:384: in _expect_failure
_expect_session()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:381: in _expect_session
child.expect("==== test session starts ====")
/usr/lib/python3.8/site-packages/pexpect/spawnbase.py:343: in expect
return self.expect_list(compiled_pattern_list,
/usr/lib/python3.8/site-packages/pexpect/spawnbase.py:372: in expect_list
return exp.expect_loop(timeout)
/usr/lib/python3.8/site-packages/pexpect/expect.py:179: in expect_loop
return self.eof(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pexpect.expect.Expecter object at 0x7f1c33c45100>, err = EOF('End Of File (EOF). Exception style platform.')
def eof(self, err=None):
spawn = self.spawn
spawn.before = spawn._before.getvalue()
spawn._buffer = spawn.buffer_type()
spawn._before = spawn.buffer_type()
spawn.after = EOF
index = self.searcher.eof_index
if index >= 0:
spawn.match = EOF
spawn.match_index = index
return index
else:
spawn.match = None
spawn.match_index = None
msg = str(spawn)
msg += '\nsearcher: %s' % self.searcher
if err is not None:
msg = str(err) + '\n' + msg
exc = EOF(msg)
exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
> raise exc
E pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
E <pexpect.pty_spawn.spawn object at 0x7f1c33c45580>
E command: /usr/bin/python3
E args: ['/usr/bin/python3', '-mpytest', '--basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_looponfail0/temp-pexpect', '--mypy', '--looponfail', '/tmp/pytest-of-tkloczko/pytest-57/test_looponfail0/looponfailroot/__init__.py']
E buffer (last 100 chars): b''
E before (last 100 chars): b'ytest-57/test_looponfail0/tox.ini\r\n rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_looponfail0\r\n\r\n'
E after: <class 'pexpect.exceptions.EOF'>
E match: None
E match_index: None
E exitstatus: None
E flag_eof: True
E pid: 2942620
E child_fd: 16
E closed: False
E timeout: 30.0
E delimiter: <class 'pexpect.exceptions.EOF'>
E logfile: <_io.BufferedWriter name='/tmp/pytest-of-tkloczko/pytest-57/test_looponfail0/spawn.out'>
E logfile_read: None
E logfile_send: None
E maxread: 2000
E ignorecase: False
E searchwindowsize: None
E delaybeforesend: 0.05
E delayafterclose: 0.1
E delayafterterminate: 0.1
E searcher: searcher_re:
E 0: re.compile(b'==== test session starts ====')
/usr/lib/python3.8/site-packages/pexpect/expect.py:122: EOF
________________________________________________________________________ test_looponfail[test_demo] ________________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_looponfail1')>, module_name = 'test_demo'
@pytest.mark.parametrize("module_name", ["__init__", "test_demo"])
def test_looponfail(testdir, module_name):
"""Ensure that the plugin works with --looponfail."""
pass_source = textwrap.dedent(
"""\
def pyfunc(x: int) -> int:
return x * 2
""",
)
fail_source = textwrap.dedent(
"""\
def pyfunc(x: int) -> str:
return x * 2
""",
)
pyfile = testdir.makepyfile(**{module_name: fail_source})
looponfailroot = testdir.mkdir("looponfailroot")
looponfailroot_pyfile = looponfailroot.join(pyfile.basename)
pyfile.move(looponfailroot_pyfile)
pyfile = looponfailroot_pyfile
testdir.makeini(
textwrap.dedent(
"""\
[pytest]
looponfailroots = {looponfailroots}
""".format(
looponfailroots=looponfailroot,
),
),
)
child = testdir.spawn_pytest(
"--mypy --looponfail " + str(pyfile),
expect_timeout=30.0,
)
num_tests = 2
if module_name == "__init__" and (3, 10) <= PYTEST_VERSION < (6, 2):
# https://github.com/pytest-dev/pytest/issues/8016
# Pytest had a bug where it assumed only a Package would have a basename of
# __init__.py. In this test, Pytest mistakes MypyFile for a Package and
# returns after collecting only one object (the MypyFileItem).
num_tests = 1
def _expect_session():
child.expect("==== test session starts ====")
def _expect_failure():
_expect_session()
child.expect("==== FAILURES ====")
child.expect(pyfile.basename + " ____")
child.expect("2: error: Incompatible return value")
# if num_tests == 2:
# # These only show with mypy>=0.730:
# child.expect("==== mypy ====")
# child.expect("Found 1 error in 1 file (checked 1 source file)")
child.expect(str(num_tests) + " failed")
child.expect("#### LOOPONFAILING ####")
_expect_waiting()
def _expect_waiting():
child.expect("#### waiting for changes ####")
child.expect("Watching")
def _fix():
pyfile.write(pass_source)
_expect_changed()
_expect_success()
def _expect_changed():
child.expect("MODIFIED " + str(pyfile))
def _expect_success():
for _ in range(2):
_expect_session()
# if num_tests == 2:
# # These only show with mypy>=0.730:
# child.expect("==== mypy ====")
# child.expect("Success: no issues found in 1 source file")
try:
child.expect(str(num_tests) + " passed")
except pexpect.exceptions.TIMEOUT:
if module_name == "__init__" and (6, 0) <= PYTEST_VERSION < (6, 2):
# MypyItems hit the __init__.py bug too when --looponfail
# re-collects them after the failing file is modified.
# Unlike MypyFile, MypyItem is not a Collector, so this used
# to cause an AttributeError until a workaround was added
# (MypyItem.collect was defined to yield itself).
# Mypy probably noticed the __init__.py problem during the
# development of Pytest 6.0, but the error was addressed
# with an isinstance assertion, which broke the workaround.
# Here, we hit that assertion:
child.expect("AssertionError")
child.expect("1 error")
pytest.xfail("https://github.com/pytest-dev/pytest/issues/8016")
raise
_expect_waiting()
def _break():
pyfile.write(fail_source)
_expect_changed()
_expect_failure()
> _expect_failure()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:439:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:384: in _expect_failure
_expect_session()
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:381: in _expect_session
child.expect("==== test session starts ====")
/usr/lib/python3.8/site-packages/pexpect/spawnbase.py:343: in expect
return self.expect_list(compiled_pattern_list,
/usr/lib/python3.8/site-packages/pexpect/spawnbase.py:372: in expect_list
return exp.expect_loop(timeout)
/usr/lib/python3.8/site-packages/pexpect/expect.py:179: in expect_loop
return self.eof(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pexpect.expect.Expecter object at 0x7f1c339738e0>, err = EOF('End Of File (EOF). Exception style platform.')
def eof(self, err=None):
spawn = self.spawn
spawn.before = spawn._before.getvalue()
spawn._buffer = spawn.buffer_type()
spawn._before = spawn.buffer_type()
spawn.after = EOF
index = self.searcher.eof_index
if index >= 0:
spawn.match = EOF
spawn.match_index = index
return index
else:
spawn.match = None
spawn.match_index = None
msg = str(spawn)
msg += '\nsearcher: %s' % self.searcher
if err is not None:
msg = str(err) + '\n' + msg
exc = EOF(msg)
exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
> raise exc
E pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
E <pexpect.pty_spawn.spawn object at 0x7f1c33973a00>
E command: /usr/bin/python3
E args: ['/usr/bin/python3', '-mpytest', '--basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_looponfail1/temp-pexpect', '--mypy', '--looponfail', '/tmp/pytest-of-tkloczko/pytest-57/test_looponfail1/looponfailroot/test_demo.py']
E buffer (last 100 chars): b''
E before (last 100 chars): b'ytest-57/test_looponfail1/tox.ini\r\n rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_looponfail1\r\n\r\n'
E after: <class 'pexpect.exceptions.EOF'>
E match: None
E match_index: None
E exitstatus: None
E flag_eof: True
E pid: 2942622
E child_fd: 17
E closed: False
E timeout: 30.0
E delimiter: <class 'pexpect.exceptions.EOF'>
E logfile: <_io.BufferedWriter name='/tmp/pytest-of-tkloczko/pytest-57/test_looponfail1/spawn.out'>
E logfile_read: None
E logfile_send: None
E maxread: 2000
E ignorecase: False
E searchwindowsize: None
E delaybeforesend: 0.05
E delayafterclose: 0.1
E delayafterterminate: 0.1
E searcher: searcher_re:
E 0: re.compile(b'==== test session starts ====')
/usr/lib/python3.8/site-packages/pexpect/expect.py:122: EOF
_______________________________________________________________________ test_mypy_item_collect[True] _______________________________________________________________________
testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-57/test_mypy_item_collect0')>, xdist_args = ['-n', 'auto']
def test_mypy_item_collect(testdir, xdist_args):
"""Ensure coverage for a 3.10<=pytest<6.0 workaround."""
testdir.makepyfile(
"""
def test_mypy_item_collect(request):
plugin = request.config.pluginmanager.getplugin("mypy")
mypy_items = [
item
for item in request.session.items
if isinstance(item, plugin.MypyItem)
]
assert mypy_items
for mypy_item in mypy_items:
assert all(item is mypy_item for item in mypy_item.collect())
""",
)
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
test_count = 1
mypy_file_checks = 1
mypy_status_check = 1
> result.assert_outcomes(passed=test_count + mypy_file_checks + mypy_status_check)
/home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1/tests/test_pytest_mypy.py:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/pytester.py:542: in parseoutcomes
return self.parse_summary_nouns(self.outlines)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class '_pytest.pytester.RunResult'>, lines = []
@classmethod
def parse_summary_nouns(cls, lines) -> Dict[str, int]:
"""Extract the nouns from a pytest terminal summary line.
It always returns the plural noun for consistency::
======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====
Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
"""
for line in reversed(lines):
if rex_session_duration.search(line):
outcomes = rex_outcome.findall(line)
ret = {noun: int(count) for (count, noun) in outcomes}
break
else:
> raise ValueError("Pytest terminal summary report not found")
E ValueError: Pytest terminal summary report not found
/usr/lib/python3.8/site-packages/_pytest/pytester.py:560: ValueError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-tkloczko/pytest-57/test_mypy_item_collect0/runpytest-0 --mypy -n auto
in: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_item_collect0
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n
inifile: None
rootdir: /tmp/pytest-of-tkloczko/pytest-57/test_mypy_item_collect0
========================================================================= short test summary info ==========================================================================
FAILED tests/test_pytest_mypy.py::test_mypy_success[True-1] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_success[True-2] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_pyi[True] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_error[True] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_ignore_missings_imports[True] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_marker[True] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_non_mypy_error[True] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_stderr[True] - Failed: remains unmatched: 'This is stderr from mypy.'
FAILED tests/test_pytest_mypy.py::test_mypy_unmatched_stdout[True] - Failed: remains unmatched: 'This is unexpected output on stdout from mypy.'
FAILED tests/test_pytest_mypy.py::test_api_mypy_argv[True] - assert <ExitCode.USAGE_ERROR: 4> == 0
FAILED tests/test_pytest_mypy.py::test_api_nodeid_name[True] - Failed: remains unmatched: '*conftest.py::UnmistakableNodeIDName*'
FAILED tests/test_pytest_mypy.py::test_mypy_indirect[True-__init__] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_mypy_indirect[True-good] - ValueError: Pytest terminal summary report not found
FAILED tests/test_pytest_mypy.py::test_api_error_formatter[True] - Failed: remains unmatched: '*/bad.py:2: error: Incompatible return value*'
FAILED tests/test_pytest_mypy.py::test_setup_cfg[True] - Failed: remains unmatched: '1: error: Function is missing a type annotation'
FAILED tests/test_pytest_mypy.py::test_looponfail[__init__] - pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
FAILED tests/test_pytest_mypy.py::test_looponfail[test_demo] - pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
FAILED tests/test_pytest_mypy.py::test_mypy_item_collect[True] - ValueError: Pytest terminal summary report not found
================================================================ 18 failed, 32 passed in 162.28s (0:02:42) ================================================================= |
Looks like you need to install |
sh*t .. one sec :) |
OK closing. + /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-mypy-0.8.1, configfile: tox.ini, testpaths: tests
plugins: mypy-0.8.1, forked-1.4.0, xdist-2.5.0
collected 50 items
tests/test_pytest_mypy.py .................................................. [100%]
====================================================================== 50 passed in 290.96s (0:04:50) ====================================================================== |
I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
May I ask where I can find that
is_always_missing
module? I canmot find it on pypi :/Here is pytest output:
The text was updated successfully, but these errors were encountered: