tests: fix tests that require PYTEST_DISABLE_PLUGIN_AUTOLOAD to be unset

Fix pytest's own tests with PYTEST_DISABLE_PLUGIN_AUTOLOAD=1.
This commit is contained in:
Daniel Hahler 2018-12-09 11:53:41 +01:00
parent 818aa4d343
commit 64ee1ee81b
4 changed files with 15 additions and 6 deletions

View File

@ -153,7 +153,8 @@ class TestImportHookInstallation(object):
@pytest.mark.parametrize("mode", ["plain", "rewrite"]) @pytest.mark.parametrize("mode", ["plain", "rewrite"])
@pytest.mark.parametrize("plugin_state", ["development", "installed"]) @pytest.mark.parametrize("plugin_state", ["development", "installed"])
def test_installed_plugin_rewrite(self, testdir, mode, plugin_state): def test_installed_plugin_rewrite(self, testdir, mode, plugin_state, monkeypatch):
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
# Make sure the hook is installed early enough so that plugins # Make sure the hook is installed early enough so that plugins
# installed via setuptools are rewritten. # installed via setuptools are rewritten.
testdir.tmpdir.join("hampkg").ensure(dir=1) testdir.tmpdir.join("hampkg").ensure(dir=1)

View File

@ -511,6 +511,7 @@ def test_options_on_small_file_do_not_blow_up(testdir):
def test_preparse_ordering_with_setuptools(testdir, monkeypatch): def test_preparse_ordering_with_setuptools(testdir, monkeypatch):
pkg_resources = pytest.importorskip("pkg_resources") pkg_resources = pytest.importorskip("pkg_resources")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
def my_iter(name): def my_iter(name):
assert name == "pytest11" assert name == "pytest11"
@ -548,6 +549,7 @@ def test_preparse_ordering_with_setuptools(testdir, monkeypatch):
def test_setuptools_importerror_issue1479(testdir, monkeypatch): def test_setuptools_importerror_issue1479(testdir, monkeypatch):
pkg_resources = pytest.importorskip("pkg_resources") pkg_resources = pytest.importorskip("pkg_resources")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
def my_iter(name): def my_iter(name):
assert name == "pytest11" assert name == "pytest11"
@ -576,6 +578,7 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch):
@pytest.mark.parametrize("block_it", [True, False]) @pytest.mark.parametrize("block_it", [True, False])
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it): def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
pkg_resources = pytest.importorskip("pkg_resources") pkg_resources = pytest.importorskip("pkg_resources")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
plugin_module_placeholder = object() plugin_module_placeholder = object()

View File

@ -1032,12 +1032,13 @@ def test_record_attribute(testdir):
) )
def test_random_report_log_xdist(testdir): def test_random_report_log_xdist(testdir, monkeypatch):
"""xdist calls pytest_runtest_logreport as they are executed by the slaves, """xdist calls pytest_runtest_logreport as they are executed by the slaves,
with nodes from several nodes overlapping, so junitxml must cope with that with nodes from several nodes overlapping, so junitxml must cope with that
to produce correct reports. #1064 to produce correct reports. #1064
""" """
pytest.importorskip("xdist") pytest.importorskip("xdist")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
testdir.makepyfile( testdir.makepyfile(
""" """
import pytest, time import pytest, time

View File

@ -1331,13 +1331,15 @@ class TestProgressOutputStyle(object):
] ]
) )
def test_xdist_normal(self, many_tests_files, testdir): def test_xdist_normal(self, many_tests_files, testdir, monkeypatch):
pytest.importorskip("xdist") pytest.importorskip("xdist")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
output = testdir.runpytest("-n2") output = testdir.runpytest("-n2")
output.stdout.re_match_lines([r"\.{20} \s+ \[100%\]"]) output.stdout.re_match_lines([r"\.{20} \s+ \[100%\]"])
def test_xdist_normal_count(self, many_tests_files, testdir): def test_xdist_normal_count(self, many_tests_files, testdir, monkeypatch):
pytest.importorskip("xdist") pytest.importorskip("xdist")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
testdir.makeini( testdir.makeini(
""" """
[pytest] [pytest]
@ -1347,8 +1349,9 @@ class TestProgressOutputStyle(object):
output = testdir.runpytest("-n2") output = testdir.runpytest("-n2")
output.stdout.re_match_lines([r"\.{20} \s+ \[20/20\]"]) output.stdout.re_match_lines([r"\.{20} \s+ \[20/20\]"])
def test_xdist_verbose(self, many_tests_files, testdir): def test_xdist_verbose(self, many_tests_files, testdir, monkeypatch):
pytest.importorskip("xdist") pytest.importorskip("xdist")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
output = testdir.runpytest("-n2", "-v") output = testdir.runpytest("-n2", "-v")
output.stdout.re_match_lines_random( output.stdout.re_match_lines_random(
[ [
@ -1442,7 +1445,8 @@ class TestProgressWithTeardown(object):
] ]
) )
def test_xdist_normal(self, many_files, testdir): def test_xdist_normal(self, many_files, testdir, monkeypatch):
pytest.importorskip("xdist") pytest.importorskip("xdist")
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
output = testdir.runpytest("-n2") output = testdir.runpytest("-n2")
output.stdout.re_match_lines([r"[\.E]{40} \s+ \[100%\]"]) output.stdout.re_match_lines([r"[\.E]{40} \s+ \[100%\]"])