tests: harden test_config_error

This commit is contained in:
Daniel Hahler 2018-11-09 01:31:53 +01:00
parent 401a3cd1bc
commit a0890f98d8
2 changed files with 6 additions and 1 deletions

View File

@ -27,8 +27,9 @@ class TestGeneralUsage(object):
def test_config_error(self, testdir): def test_config_error(self, testdir):
testdir.copy_example("conftest_usageerror/conftest.py") testdir.copy_example("conftest_usageerror/conftest.py")
result = testdir.runpytest(testdir.tmpdir) result = testdir.runpytest(testdir.tmpdir)
assert result.ret != 0 assert result.ret == EXIT_USAGEERROR
result.stderr.fnmatch_lines(["*ERROR: hello"]) result.stderr.fnmatch_lines(["*ERROR: hello"])
result.stdout.fnmatch_lines(["*pytest_unconfigure_called"])
def test_root_conftest_syntax_error(self, testdir): def test_root_conftest_syntax_error(self, testdir):
testdir.makepyfile(conftest="raise SyntaxError\n") testdir.makepyfile(conftest="raise SyntaxError\n")

View File

@ -2,3 +2,7 @@ def pytest_configure(config):
import pytest import pytest
raise pytest.UsageError("hello") raise pytest.UsageError("hello")
def pytest_unconfigure(config):
print("pytest_unconfigure_called")