Merge branch 'master' into features
This commit is contained in:
@@ -27,8 +27,9 @@ class TestGeneralUsage(object):
|
||||
def test_config_error(self, testdir):
|
||||
testdir.copy_example("conftest_usageerror/conftest.py")
|
||||
result = testdir.runpytest(testdir.tmpdir)
|
||||
assert result.ret != 0
|
||||
assert result.ret == EXIT_USAGEERROR
|
||||
result.stderr.fnmatch_lines(["*ERROR: hello"])
|
||||
result.stdout.fnmatch_lines(["*pytest_unconfigure_called"])
|
||||
|
||||
def test_root_conftest_syntax_error(self, testdir):
|
||||
testdir.makepyfile(conftest="raise SyntaxError\n")
|
||||
|
||||
@@ -2,3 +2,7 @@ def pytest_configure(config):
|
||||
import pytest
|
||||
|
||||
raise pytest.UsageError("hello")
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
print("pytest_unconfigure_called")
|
||||
|
||||
@@ -136,5 +136,5 @@ def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardow
|
||||
|
||||
assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
|
||||
|
||||
# This reachers into private API, don't use this type of thing in real tests!
|
||||
# This reaches into private API, don't use this type of thing in real tests!
|
||||
assert set(caplog._item.catch_log_handlers.keys()) == {"setup", "call"}
|
||||
|
||||
@@ -874,7 +874,7 @@ class TestRootdir(object):
|
||||
assert inifile == inifile
|
||||
|
||||
@pytest.mark.parametrize("name", "setup.cfg tox.ini".split())
|
||||
def test_pytestini_overides_empty_other(self, tmpdir, name):
|
||||
def test_pytestini_overrides_empty_other(self, tmpdir, name):
|
||||
inifile = tmpdir.ensure("pytest.ini")
|
||||
a = tmpdir.mkdir("a")
|
||||
a.ensure(name)
|
||||
|
||||
@@ -19,13 +19,19 @@ def test_fileimport(modfile):
|
||||
# without needing the pytest namespace being set
|
||||
# this is critical for the initialization of xdist
|
||||
|
||||
res = subprocess.call(
|
||||
p = subprocess.Popen(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
"import sys, py; py.path.local(sys.argv[1]).pyimport()",
|
||||
modfile.strpath,
|
||||
]
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
if res:
|
||||
pytest.fail("command result %s" % res)
|
||||
(out, err) = p.communicate()
|
||||
if p.returncode != 0:
|
||||
pytest.fail(
|
||||
"importing %s failed (exitcode %d): out=%r, err=%r"
|
||||
% (modfile, p.returncode, out, err)
|
||||
)
|
||||
|
||||
@@ -380,3 +380,21 @@ class TestPytestPluginManagerBootstrapming(object):
|
||||
pytestpm.consider_preparse(["xyz", "-p", "no:abc"])
|
||||
l2 = pytestpm.get_plugins()
|
||||
assert 42 not in l2
|
||||
|
||||
def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister(
|
||||
self, pytestpm
|
||||
):
|
||||
""" From PR #4304 : The only way to unregister a module is documented at
|
||||
the end of https://docs.pytest.org/en/latest/plugins.html.
|
||||
|
||||
When unregister cacheprovider, then unregister stepwise too
|
||||
"""
|
||||
pytestpm.register(42, name="cacheprovider")
|
||||
pytestpm.register(43, name="stepwise")
|
||||
l1 = pytestpm.get_plugins()
|
||||
assert 42 in l1
|
||||
assert 43 in l1
|
||||
pytestpm.consider_preparse(["xyz", "-p", "no:cacheprovider"])
|
||||
l2 = pytestpm.get_plugins()
|
||||
assert 42 not in l2
|
||||
assert 43 not in l2
|
||||
|
||||
Reference in New Issue
Block a user