Skip to content
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

py36+: remove _pytest.compat.MODULE_NOT_FOUND_ERROR #7833

Merged
merged 1 commit into from Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/_pytest/compat.py
Expand Up @@ -46,11 +46,6 @@ class NotSetType(enum.Enum):
NOTSET = NotSetType.token # type: Final # noqa: E305
# fmt: on

MODULE_NOT_FOUND_ERROR = (
"ModuleNotFoundError" if sys.version_info[:2] >= (3, 6) else "ImportError"
)


if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata
else:
Expand Down
5 changes: 1 addition & 4 deletions testing/acceptance_test.py
Expand Up @@ -210,17 +210,14 @@ def foo():
"""
)
result = testdir.runpytest()
exc_name = (
"ModuleNotFoundError" if sys.version_info >= (3, 6) else "ImportError"
)
assert result.stdout.lines == []
assert result.stderr.lines == [
"ImportError while loading conftest '{}'.".format(conftest),
"conftest.py:3: in <module>",
" foo()",
"conftest.py:2: in foo",
" import qwerty",
"E {}: No module named 'qwerty'".format(exc_name),
"E ModuleNotFoundError: No module named 'qwerty'",
]

def test_early_skip(self, testdir):
Expand Down
7 changes: 2 additions & 5 deletions testing/test_collection.py
Expand Up @@ -1383,13 +1383,10 @@ def test_modules_not_importable_as_side_effect(self, testdir):
"""
self.setup_conftest_and_foo(testdir)
result = testdir.runpytest("-v", "--import-mode=importlib")
exc_name = (
"ModuleNotFoundError" if sys.version_info[:2] > (3, 5) else "ImportError"
)
result.stdout.fnmatch_lines(
[
"*{}: No module named 'foo'".format(exc_name),
"tests?test_foo.py:2: {}".format(exc_name),
"*ModuleNotFoundError: No module named 'foo'",
"tests?test_foo.py:2: ModuleNotFoundError",
"* 1 failed in *",
]
)
Expand Down
7 changes: 3 additions & 4 deletions testing/test_doctest.py
Expand Up @@ -4,7 +4,6 @@
from typing import Optional

import pytest
from _pytest.compat import MODULE_NOT_FOUND_ERROR
from _pytest.doctest import _get_checker
from _pytest.doctest import _is_mocked
from _pytest.doctest import _is_setup_py
Expand Down Expand Up @@ -399,8 +398,8 @@ def test_doctest_unex_importerror_only_txt(self, testdir):
result.stdout.fnmatch_lines(
[
"*>>> import asdals*",
"*UNEXPECTED*{e}*".format(e=MODULE_NOT_FOUND_ERROR),
"{e}: No module named *asdal*".format(e=MODULE_NOT_FOUND_ERROR),
"*UNEXPECTED*ModuleNotFoundError*",
"ModuleNotFoundError: No module named *asdal*",
]
)

Expand All @@ -423,7 +422,7 @@ def test_doctest_unex_importerror_with_module(self, testdir):
result.stdout.fnmatch_lines(
[
"*ERROR collecting hello.py*",
"*{e}: No module named *asdals*".format(e=MODULE_NOT_FOUND_ERROR),
"*ModuleNotFoundError: No module named *asdals*",
"*Interrupted: 1 error during collection*",
]
)
Expand Down