diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8e0ba82e4..22f3ac862 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,31 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 4.0.2 (2018-12-13) +========================= + +Bug Fixes +--------- + +- `#4265 `_: Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately. + + +- `#4435 `_: Fix ``raises(..., 'code(string)')`` frame filename. + + +- `#4500 `_: When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are ``None``. + + +- `#4538 `_: Raise ``TypeError`` for ``with raises(..., match=)``. + + + +Improved Documentation +---------------------- + +- `#1495 `_: Document common doctest fixture directory tree structure pitfalls + + pytest 4.0.1 (2018-11-23) ========================= diff --git a/changelog/1495.doc.rst b/changelog/1495.doc.rst deleted file mode 100644 index ab7231333..000000000 --- a/changelog/1495.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Document common doctest fixture directory tree structure pitfalls diff --git a/changelog/4265.bugfix.rst b/changelog/4265.bugfix.rst deleted file mode 100644 index 7b40737c3..000000000 --- a/changelog/4265.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately. diff --git a/changelog/4500.bugfix.rst b/changelog/4500.bugfix.rst deleted file mode 100644 index b84b6b117..000000000 --- a/changelog/4500.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are ``None``. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 4120ccfc9..d6379f1b3 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-4.0.2 release-4.0.1 release-4.0.0 release-3.10.1 diff --git a/doc/en/announce/release-4.0.2.rst b/doc/en/announce/release-4.0.2.rst new file mode 100644 index 000000000..3b6e4be71 --- /dev/null +++ b/doc/en/announce/release-4.0.2.rst @@ -0,0 +1,24 @@ +pytest-4.0.2 +======================================= + +pytest 4.0.2 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* Bruno Oliveira +* Daniel Hahler +* Pedro Algarvio +* Ronny Pfannschmidt +* Tomer Keren +* Yash Todi + + +Happy testing, +The pytest Development Team diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index bb8ea5996..d4540fe5e 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -538,7 +538,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: $ pytest -v -m basic =========================== test session starts ============================ - platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python + platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache rootdir: $REGENDOC_TMPDIR, inifile: collecting ... collected 17 items / 14 deselected diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 33e88b409..92674589f 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -718,6 +718,6 @@ class RaisesContext(object): suppress_exception = issubclass(self.excinfo.type, self.expected_exception) if sys.version_info[0] == 2 and suppress_exception: sys.exc_clear() - if self.match_expr and suppress_exception: + if self.match_expr is not None and suppress_exception: self.excinfo.match(self.match_expr) return suppress_exception diff --git a/testing/python/raises.py b/testing/python/raises.py index aad60d775..4ff0b51bc 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -44,6 +44,11 @@ class TestRaises(object): except pytest.raises.Exception: pass + def test_raises_falsey_type_error(self): + with pytest.raises(TypeError): + with pytest.raises(AssertionError, match=0): + raise AssertionError("ohai") + def test_raises_repr_inflight(self): """Ensure repr() on an exception info inside a pytest.raises with block works (#4386)""" diff --git a/testing/test_assertion.py b/testing/test_assertion.py index bb54e394f..fcefdbb11 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -154,7 +154,8 @@ class TestImportHookInstallation(object): @pytest.mark.parametrize("mode", ["plain", "rewrite"]) @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 # installed via setuptools are rewritten. testdir.tmpdir.join("hampkg").ensure(dir=1) diff --git a/testing/test_config.py b/testing/test_config.py index 012b8936c..6f53ecebb 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -511,6 +511,7 @@ def test_options_on_small_file_do_not_blow_up(testdir): def test_preparse_ordering_with_setuptools(testdir, monkeypatch): pkg_resources = pytest.importorskip("pkg_resources") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) def my_iter(name): assert name == "pytest11" @@ -548,6 +549,7 @@ def test_preparse_ordering_with_setuptools(testdir, monkeypatch): def test_setuptools_importerror_issue1479(testdir, monkeypatch): pkg_resources = pytest.importorskip("pkg_resources") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) def my_iter(name): assert name == "pytest11" @@ -576,6 +578,7 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch): @pytest.mark.parametrize("block_it", [True, False]) def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it): pkg_resources = pytest.importorskip("pkg_resources") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) plugin_module_placeholder = object() diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index aafbb8da9..4ae4d6246 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1050,12 +1050,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, with nodes from several nodes overlapping, so junitxml must cope with that to produce correct reports. #1064 """ pytest.importorskip("xdist") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) testdir.makepyfile( """ import pytest, time diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 20f4f0078..9cd79afcf 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1341,13 +1341,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") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) output = testdir.runpytest("-n2") 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") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) testdir.makeini( """ [pytest] @@ -1357,8 +1359,9 @@ class TestProgressOutputStyle(object): output = testdir.runpytest("-n2") 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") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) output = testdir.runpytest("-n2", "-v") output.stdout.re_match_lines_random( [ @@ -1452,7 +1455,8 @@ class TestProgressWithTeardown(object): ] ) - def test_xdist_normal(self, many_files, testdir): + def test_xdist_normal(self, many_files, testdir, monkeypatch): pytest.importorskip("xdist") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) output = testdir.runpytest("-n2") output.stdout.re_match_lines([r"[\.E]{40} \s+ \[100%\]"])