diff --git a/doc/en/reference.rst b/doc/en/reference.rst index bd89d024d..7c5ee2e4b 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -1,4 +1,3 @@ - Reference ========= @@ -49,7 +48,7 @@ pytest.main .. autofunction:: _pytest.config.main pytest.param -~~~~~~~~~~~~~ +~~~~~~~~~~~~ .. autofunction:: pytest.param(*values, [id], [marks]) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 4e3700b1e..19553ca0e 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -225,7 +225,7 @@ def wrap_session(config, doit): config.notify_exception(excinfo, config.option) session.exitstatus = EXIT_INTERNALERROR if excinfo.errisinstance(SystemExit): - sys.stderr.write("mainloop: caught Spurious SystemExit!\n") + sys.stderr.write("mainloop: caught unexpected SystemExit!\n") finally: excinfo = None # Explicitly break reference cycle. diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 764985736..3360aea9c 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -103,8 +103,9 @@ def catch_warnings_for_item(config, ihook, when, item): def warning_record_to_str(warning_message): - """Convert a warnings.WarningMessage to a string, taking in account a lot of unicode shenaningans in Python 2. + """Convert a warnings.WarningMessage to a string. + This takes lot of unicode shenaningans into account for Python 2. When Python 2 support is dropped this function can be greatly simplified. """ warn_msg = warning_message.message diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index bed7d7080..408fa076e 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -677,6 +677,8 @@ class TestInvocationVariants(object): def test_cmdline_python_namespace_package(self, testdir, monkeypatch): """ test --pyargs option with namespace packages (#1567) + + Ref: https://packaging.python.org/guides/packaging-namespace-packages/ """ monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 4f30157f4..aed203b70 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -54,6 +54,7 @@ def test_root_logger_affected(testdir): """ import logging logger = logging.getLogger() + def test_foo(): logger.info('info text ' + 'going to logger') logger.warning('warning text ' + 'going to logger') @@ -66,15 +67,14 @@ def test_root_logger_affected(testdir): result = testdir.runpytest("--log-level=ERROR", "--log-file=pytest.log") assert result.ret == 1 - # the capture log calls in the stdout section only contain the - # logger.error msg, because --log-level=ERROR + # The capture log calls in the stdout section only contain the + # logger.error msg, because of --log-level=ERROR. result.stdout.fnmatch_lines(["*error text going to logger*"]) - with pytest.raises(pytest.fail.Exception): - result.stdout.fnmatch_lines(["*warning text going to logger*"]) - with pytest.raises(pytest.fail.Exception): - result.stdout.fnmatch_lines(["*info text going to logger*"]) + stdout = result.stdout.str() + assert "warning text going to logger" not in stdout + assert "info text going to logger" not in stdout - # the log file should contain the warning and the error log messages and + # The log file should contain the warning and the error log messages and # not the info one, because the default level of the root logger is # WARNING. assert os.path.isfile(log_file) @@ -635,7 +635,6 @@ def test_log_cli_auto_enable(testdir, request, cli_args): """ testdir.makepyfile( """ - import pytest import logging def test_log_1(): @@ -653,6 +652,7 @@ def test_log_cli_auto_enable(testdir, request, cli_args): ) result = testdir.runpytest(cli_args) + stdout = result.stdout.str() if cli_args == "--log-cli-level=WARNING": result.stdout.fnmatch_lines( [ @@ -663,13 +663,13 @@ def test_log_cli_auto_enable(testdir, request, cli_args): "=* 1 passed in *=", ] ) - assert "INFO" not in result.stdout.str() + assert "INFO" not in stdout else: result.stdout.fnmatch_lines( ["*test_log_cli_auto_enable*100%*", "=* 1 passed in *="] ) - assert "INFO" not in result.stdout.str() - assert "WARNING" not in result.stdout.str() + assert "INFO" not in stdout + assert "WARNING" not in stdout def test_log_file_cli(testdir): diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 7639d332e..a1b4a86b5 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -884,7 +884,7 @@ class TestReadme(object): def test_readme_failed(self, testdir): testdir.makepyfile( """ - def test_always_passes(): + def test_always_fails(): assert 0 """ ) diff --git a/testing/test_session.py b/testing/test_session.py index 20079cd1b..e09b08a3d 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -124,14 +124,14 @@ class SessionTests(object): ) reprec = testdir.inline_run(p) passed, skipped, failed = reprec.listoutcomes() - assert len(failed) == 1 + assert (len(passed), len(skipped), len(failed)) == (1, 0, 1) out = failed[0].longrepr.reprcrash.message assert ( out.find( """[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""" ) != -1 - ) # ' + ) def test_skip_file_by_conftest(self, testdir): testdir.makepyfile( diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 1f3fff8c5..e8590b1ba 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -660,7 +660,6 @@ class TestTerminalFunctional(object): ) def test_verbose_reporting(self, verbose_testfile, testdir, pytestconfig): - result = testdir.runpytest( verbose_testfile, "-v", "-Walways::pytest.PytestWarning" ) diff --git a/tox.ini b/tox.ini index 97cac6f6b..91a09be32 100644 --- a/tox.ini +++ b/tox.ini @@ -81,7 +81,6 @@ commands = {[testenv:py27-trial]commands} [testenv:docs] basepython = python3 -skipsdist = True usedevelop = True changedir = doc/en deps = -r{toxinidir}/doc/en/requirements.txt @@ -135,7 +134,6 @@ commands = [testenv:release] decription = do a release, required posarg of the version number basepython = python3.6 -skipsdist = True usedevelop = True passenv = * deps =