From 5a544d4fac810b28465eac27f431866ae22bf118 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 19 Nov 2018 12:49:38 +0100 Subject: [PATCH 01/10] tox.ini: usedevelop implies skipsdist --- tox.ini | 2 -- 1 file changed, 2 deletions(-) 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 = From 5c26ba9cb17edca3f5b978e0a037bc8885a95437 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 10 Dec 2018 05:19:26 +0100 Subject: [PATCH 02/10] minor: wrap_session: s/Spurious/unexpected/ --- src/_pytest/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 3effbfb6e..e08b1fa1d 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. From ade773390ac919f3850d634065e43b4eac89d992 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 4 Mar 2019 16:42:51 +0100 Subject: [PATCH 03/10] minor: rename inner test --- testing/test_cacheprovider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 35a7232ab..082b097ee 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 """ ) From 8e125c9759b704abc376758b97a7920ab8724c95 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 16 Mar 2019 12:06:33 +0100 Subject: [PATCH 04/10] doc/en/reference.rst: whitespace/alignment --- doc/en/reference.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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]) From 7a6bcc363934f4fc8cce4115d24118a72ed35f11 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 22 Mar 2019 13:22:57 +0100 Subject: [PATCH 05/10] Add reference to test_cmdline_python_namespace_package --- testing/acceptance_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 39bd2fd77..1342a416e 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) From 6352cf23742c53f3312f3a004c762a077bdb73d7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 24 Mar 2019 11:15:40 +0100 Subject: [PATCH 06/10] test_implicit_bad_repr1: harden/cleanup --- testing/test_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/test_session.py b/testing/test_session.py index e5eb081d4..b3aaf571d 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -126,14 +126,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( From d44e42ec1501ae9ee42f00578db8f2b4a55e26e6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 24 Mar 2019 11:20:01 +0100 Subject: [PATCH 07/10] doc: improve warning_record_to_str --- src/_pytest/warnings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 7da7b9610ce8906cc02bac036ac7aa89713583cb Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 24 Mar 2019 11:20:24 +0100 Subject: [PATCH 08/10] minor: whitespace --- testing/logging/test_reporting.py | 1 + testing/test_terminal.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 90db8813e..744a384f7 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') 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" ) From ce59f42ce13c135fe27054c81467755de67268b3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 24 Mar 2019 11:21:13 +0100 Subject: [PATCH 09/10] revisit test_root_logger_affected --- testing/logging/test_reporting.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 744a384f7..c64c4cb56 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -67,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) From 5efe6ab93c1b1ce74825d540e87e8e72b7f09a1e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 24 Mar 2019 11:22:07 +0100 Subject: [PATCH 10/10] test_log_cli_auto_enable: get stdout once --- testing/logging/test_reporting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index c64c4cb56..f5cd2a2ce 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -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):