diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 839b4c439..533eb9c15 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,164 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 4.4.0 (2019-03-29) +========================= + +Features +-------- + +- `#2224 `_: ``async`` test functions are skipped and a warning is emitted when a suitable + async plugin is not installed (such as ``pytest-asyncio`` or ``pytest-trio``). + + Previously ``async`` functions would not execute at all but still be marked as "passed". + + +- `#2482 `_: Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk. + + +- `#4718 `_: The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just + by module name. + + This makes it possible to early load external plugins like ``pytest-cov`` in the command-line:: + + pytest -p pytest_cov + + +- `#4855 `_: The ``--pdbcls`` option handles classes via module attributes now (e.g. + ``pdb:pdb.Pdb`` with `pdb++`_), and its validation was improved. + + .. _pdb++: https://pypi.org/project/pdbpp/ + + +- `#4875 `_: The `testpaths `__ configuration option is now displayed next + to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were + not explicitly passed in the command line. + + Also, ``inifile`` is only displayed if there's a configuration file, instead of an empty ``inifile:`` string. + + +- `#4911 `_: Doctests can be skipped now dynamically using ``pytest.skip()``. + + +- `#4920 `_: Internal refactorings have been made in order to make the implementation of the + `pytest-subtests `__ plugin + possible, which adds unittest sub-test support and a new ``subtests`` fixture as discussed in + `#1367 `__. + + For details on the internal refactorings, please see the details on the related PR. + + +- `#4931 `_: pytester's ``LineMatcher`` asserts that the passed lines are a sequence. + + +- `#4936 `_: Handle ``-p plug`` after ``-p no:plug``. + + This can be used to override a blocked plugin (e.g. in "addopts") from the + command line etc. + + +- `#4951 `_: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``. + + +- `#4956 `_: ``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs. + + This ensures to not load configuration files from the real user's home directory. + + +- `#4980 `_: Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``). + + +- `#4993 `_: The stepwise plugin reports status information now. + + +- `#5008 `_: If a ``setup.cfg`` file contains ``[tool:pytest]`` and also the no longer supported ``[pytest]`` section, pytest will use ``[tool:pytest]`` ignoring ``[pytest]``. Previously it would unconditionally error out. + + This makes it simpler for plugins to support old pytest versions. + + + +Bug Fixes +--------- + +- `#1895 `_: Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown + before the requesting fixture. + + +- `#4851 `_: pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``. + + +- `#4903 `_: Use the correct modified time for years after 2038 in rewritten ``.pyc`` files. + + +- `#4928 `_: Fix line offsets with ``ScopeMismatch`` errors. + + +- `#4957 `_: ``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``. + + Previously they were loaded (imported) always, making e.g. the ``capfd`` fixture available. + + +- `#4968 `_: The pdb ``quit`` command is handled properly when used after the ``debug`` command with `pdb++`_. + + .. _pdb++: https://pypi.org/project/pdbpp/ + + +- `#4975 `_: Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead. + + +- `#4978 `_: ``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore. + + +- `#4988 `_: Close logging's file handler explicitly when the session finishes. + + +- `#5003 `_: Fix line offset with mark collection error (off by one). + + + +Improved Documentation +---------------------- + +- `#4974 `_: Update docs for ``pytest_cmdline_parse`` hook to note availability liminations + + + +Trivial/Internal Changes +------------------------ + +- `#4718 `_: ``pluggy>=0.9`` is now required. + + +- `#4815 `_: ``funcsigs>=1.0`` is now required for Python 2.7. + + +- `#4829 `_: Some left-over internal code related to ``yield`` tests has been removed. + + +- `#4890 `_: Remove internally unused ``anypython`` fixture from the pytester plugin. + + +- `#4912 `_: Remove deprecated Sphinx directive, ``add_description_unit()``, + pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0. + + +- `#4913 `_: Fix pytest tests invocation with custom ``PYTHONPATH``. + + +- `#4965 `_: New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks. + + These hooks will be used by ``pytest-xdist``, ``pytest-subtests``, and the replacement for + resultlog to serialize and customize reports. + + They are experimental, meaning that their details might change or even be removed + completely in future patch releases without warning. + + Feedback is welcome from plugin authors and users alike. + + +- `#4987 `_: ``Collector.repr_failure`` respects the ``--tb`` option, but only defaults to ``short`` now (with ``auto``). + + pytest 4.3.1 (2019-03-11) ========================= diff --git a/changelog/1895.bugfix.rst b/changelog/1895.bugfix.rst deleted file mode 100644 index 44b921ad9..000000000 --- a/changelog/1895.bugfix.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown -before the requesting fixture. diff --git a/changelog/2224.feature.rst b/changelog/2224.feature.rst deleted file mode 100644 index 6f0df93ae..000000000 --- a/changelog/2224.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -``async`` test functions are skipped and a warning is emitted when a suitable -async plugin is not installed (such as ``pytest-asyncio`` or ``pytest-trio``). - -Previously ``async`` functions would not execute at all but still be marked as "passed". diff --git a/changelog/2482.feature.rst b/changelog/2482.feature.rst deleted file mode 100644 index 37d5138bf..000000000 --- a/changelog/2482.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk. diff --git a/changelog/4718.feature.rst b/changelog/4718.feature.rst deleted file mode 100644 index 35d5fffb9..000000000 --- a/changelog/4718.feature.rst +++ /dev/null @@ -1,6 +0,0 @@ -The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just -by module name. - -This makes it possible to early load external plugins like ``pytest-cov`` in the command-line:: - - pytest -p pytest_cov diff --git a/changelog/4718.trivial.rst b/changelog/4718.trivial.rst deleted file mode 100644 index 8b4e019bc..000000000 --- a/changelog/4718.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -``pluggy>=0.9`` is now required. diff --git a/changelog/4815.trivial.rst b/changelog/4815.trivial.rst deleted file mode 100644 index d7d91b899..000000000 --- a/changelog/4815.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -``funcsigs>=1.0`` is now required for Python 2.7. diff --git a/changelog/4829.trivial.rst b/changelog/4829.trivial.rst deleted file mode 100644 index a1935b462..000000000 --- a/changelog/4829.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Some left-over internal code related to ``yield`` tests has been removed. diff --git a/changelog/4851.bugfix.rst b/changelog/4851.bugfix.rst deleted file mode 100644 index 7b532af3e..000000000 --- a/changelog/4851.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``. diff --git a/changelog/4855.feature.rst b/changelog/4855.feature.rst deleted file mode 100644 index 274d3991f..000000000 --- a/changelog/4855.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -The ``--pdbcls`` option handles classes via module attributes now (e.g. -``pdb:pdb.Pdb`` with `pdb++`_), and its validation was improved. - -.. _pdb++: https://pypi.org/project/pdbpp/ diff --git a/changelog/4875.feature.rst b/changelog/4875.feature.rst deleted file mode 100644 index d9fb65ca5..000000000 --- a/changelog/4875.feature.rst +++ /dev/null @@ -1,5 +0,0 @@ -The `testpaths `__ configuration option is now displayed next -to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were -not explicitly passed in the command line. - -Also, ``inifile`` is only displayed if there's a configuration file, instead of an empty ``inifile:`` string. diff --git a/changelog/4890.trivial.rst b/changelog/4890.trivial.rst deleted file mode 100644 index a3a08bc11..000000000 --- a/changelog/4890.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Remove internally unused ``anypython`` fixture from the pytester plugin. diff --git a/changelog/4903.bugfix.rst b/changelog/4903.bugfix.rst deleted file mode 100644 index 116e1b0fd..000000000 --- a/changelog/4903.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Use the correct modified time for years after 2038 in rewritten ``.pyc`` files. diff --git a/changelog/4911.feature.rst b/changelog/4911.feature.rst deleted file mode 100644 index 5aef92d76..000000000 --- a/changelog/4911.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Doctests can be skipped now dynamically using ``pytest.skip()``. diff --git a/changelog/4912.trivial.rst b/changelog/4912.trivial.rst deleted file mode 100644 index 9600c833b..000000000 --- a/changelog/4912.trivial.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove deprecated Sphinx directive, ``add_description_unit()``, -pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0. diff --git a/changelog/4913.trivial.rst b/changelog/4913.trivial.rst deleted file mode 100644 index 7846775cc..000000000 --- a/changelog/4913.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Fix pytest tests invocation with custom ``PYTHONPATH``. diff --git a/changelog/4920.feature.rst b/changelog/4920.feature.rst deleted file mode 100644 index 5eb152482..000000000 --- a/changelog/4920.feature.rst +++ /dev/null @@ -1,6 +0,0 @@ -Internal refactorings have been made in order to make the implementation of the -`pytest-subtests `__ plugin -possible, which adds unittest sub-test support and a new ``subtests`` fixture as discussed in -`#1367 `__. - -For details on the internal refactorings, please see the details on the related PR. diff --git a/changelog/4928.bugfix.rst b/changelog/4928.bugfix.rst deleted file mode 100644 index 8959efacb..000000000 --- a/changelog/4928.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix line offsets with ``ScopeMismatch`` errors. diff --git a/changelog/4931.feature.rst b/changelog/4931.feature.rst deleted file mode 100644 index bfc35a4b7..000000000 --- a/changelog/4931.feature.rst +++ /dev/null @@ -1 +0,0 @@ -pytester's ``LineMatcher`` asserts that the passed lines are a sequence. diff --git a/changelog/4936.feature.rst b/changelog/4936.feature.rst deleted file mode 100644 index 744af1297..000000000 --- a/changelog/4936.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -Handle ``-p plug`` after ``-p no:plug``. - -This can be used to override a blocked plugin (e.g. in "addopts") from the -command line etc. diff --git a/changelog/4951.feature.rst b/changelog/4951.feature.rst deleted file mode 100644 index b40e03af5..000000000 --- a/changelog/4951.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``. diff --git a/changelog/4956.feature.rst b/changelog/4956.feature.rst deleted file mode 100644 index 1dfbd7e97..000000000 --- a/changelog/4956.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs. - -This ensures to not load configuration files from the real user's home directory. diff --git a/changelog/4957.bugfix.rst b/changelog/4957.bugfix.rst deleted file mode 100644 index ade73ce22..000000000 --- a/changelog/4957.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``. - -Previously they were loaded (imported) always, making e.g. the ``capfd`` fixture available. diff --git a/changelog/4965.trivial.rst b/changelog/4965.trivial.rst deleted file mode 100644 index 36db733f9..000000000 --- a/changelog/4965.trivial.rst +++ /dev/null @@ -1,9 +0,0 @@ -New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks. - -These hooks will be used by ``pytest-xdist``, ``pytest-subtests``, and the replacement for -resultlog to serialize and customize reports. - -They are experimental, meaning that their details might change or even be removed -completely in future patch releases without warning. - -Feedback is welcome from plugin authors and users alike. diff --git a/changelog/4968.bugfix.rst b/changelog/4968.bugfix.rst deleted file mode 100644 index 9ff61652e..000000000 --- a/changelog/4968.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -The pdb ``quit`` command is handled properly when used after the ``debug`` command with `pdb++`_. - -.. _pdb++: https://pypi.org/project/pdbpp/ diff --git a/changelog/4974.doc.rst b/changelog/4974.doc.rst deleted file mode 100644 index 74799c9b3..000000000 --- a/changelog/4974.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Update docs for ``pytest_cmdline_parse`` hook to note availability liminations diff --git a/changelog/4975.bugfix.rst b/changelog/4975.bugfix.rst deleted file mode 100644 index 26c93ec18..000000000 --- a/changelog/4975.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead. diff --git a/changelog/4978.bugfix.rst b/changelog/4978.bugfix.rst deleted file mode 100644 index 259daa8da..000000000 --- a/changelog/4978.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore. diff --git a/changelog/4980.feature.rst b/changelog/4980.feature.rst deleted file mode 100644 index 40f1de9c1..000000000 --- a/changelog/4980.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``). diff --git a/changelog/4987.trivial.rst b/changelog/4987.trivial.rst deleted file mode 100644 index eb79b742a..000000000 --- a/changelog/4987.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -``Collector.repr_failure`` respects ``--tbstyle``, but only defaults to ``short`` now (with ``auto``). diff --git a/changelog/4988.bugfix.rst b/changelog/4988.bugfix.rst deleted file mode 100644 index 8cc816ed6..000000000 --- a/changelog/4988.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Close logging's file handler explicitly when the session finishes. diff --git a/changelog/4993.feature.rst b/changelog/4993.feature.rst deleted file mode 100644 index b8e1ff494..000000000 --- a/changelog/4993.feature.rst +++ /dev/null @@ -1 +0,0 @@ -The stepwise plugin reports status information now. diff --git a/changelog/5003.bugfix.rst b/changelog/5003.bugfix.rst deleted file mode 100644 index 8d18a50e6..000000000 --- a/changelog/5003.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix line offset with mark collection error (off by one). diff --git a/changelog/5008.feature.rst b/changelog/5008.feature.rst deleted file mode 100644 index 17d2770fe..000000000 --- a/changelog/5008.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -If a ``setup.cfg`` file contains ``[tool:pytest]`` and also the no longer supported ``[pytest]`` section, pytest will use ``[tool:pytest]`` ignoring ``[pytest]``. Previously it would unconditionally error out. - -This makes it simpler for plugins to support old pytest versions. diff --git a/changelog/5031.bugfix.rst b/changelog/5031.bugfix.rst new file mode 100644 index 000000000..6ad80b1e3 --- /dev/null +++ b/changelog/5031.bugfix.rst @@ -0,0 +1 @@ +Environment variables are properly restored when using pytester's ``testdir`` fixture. diff --git a/doc/en/Makefile b/doc/en/Makefile index f93d84557..3f4bd9dfe 100644 --- a/doc/en/Makefile +++ b/doc/en/Makefile @@ -13,6 +13,9 @@ PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . REGENDOC_ARGS := \ + --normalize "/[ \t]+\n/\n/" \ + --normalize "~\$$REGENDOC_TMPDIR~/home/sweet/project~" \ + --normalize "~/path/to/example~/home/sweet/project~" \ --normalize "/in \d+.\d+ seconds/in 0.12 seconds/" \ --normalize "@/tmp/pytest-of-.*/pytest-\d+@PYTEST_TMPDIR@" \ --normalize "@pytest-(\d+)\\.[^ ,]+@pytest-\1.x.y@" \ @@ -38,8 +41,9 @@ help: clean: -rm -rf $(BUILDDIR)/* +regen: REGENDOC_FILES:=*.rst */*.rst regen: - PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS=-pno:hypothesis COLUMNS=76 regendoc --update *.rst */*.rst ${REGENDOC_ARGS} + PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS=-pno:hypothesis COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS} html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 96123f3fb..7e2554656 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-4.4.0 release-4.3.1 release-4.3.0 release-4.2.1 diff --git a/doc/en/announce/release-4.4.0.rst b/doc/en/announce/release-4.4.0.rst new file mode 100644 index 000000000..4c5bcbc7d --- /dev/null +++ b/doc/en/announce/release-4.4.0.rst @@ -0,0 +1,39 @@ +pytest-4.4.0 +======================================= + +The pytest team is proud to announce the 4.4.0 release! + +pytest is a mature Python testing tool with more than a 2000 tests +against itself, passing on many different interpreters and platforms. + +This release contains a number of bugs fixes and improvements, so users are encouraged +to take a look at the CHANGELOG: + + https://docs.pytest.org/en/latest/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/latest/ + +As usual, you can upgrade from pypi via: + + pip install -U pytest + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* ApaDoctor +* Bernhard M. Wiedemann +* Brian Skinn +* Bruno Oliveira +* Daniel Hahler +* Gary Tyler +* Jeong YunWon +* Miro Hrončok +* Takafumi Arakaki +* henrykironde +* smheidrich + + +Happy testing, +The Pytest Development Team diff --git a/doc/en/assert.rst b/doc/en/assert.rst index e7e78601b..9b26308c6 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -30,7 +30,7 @@ you will see the return value of the function call: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_assert1.py F [100%] @@ -165,7 +165,7 @@ if you run this module: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_assert2.py F [100%] diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 8d6a06a44..fb16140c0 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -28,25 +28,29 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. capsys - Enable capturing of writes to ``sys.stdout`` and ``sys.stderr`` and make - captured output available via ``capsys.readouterr()`` method calls - which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will be ``text`` - objects. + Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. + + The captured output is made available via ``capsys.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``text`` objects. capsysbinary - Enable capturing of writes to ``sys.stdout`` and ``sys.stderr`` and make - captured output available via ``capsys.readouterr()`` method calls - which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``bytes`` - objects. + Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. + + The captured output is made available via ``capsysbinary.readouterr()`` + method calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``bytes`` objects. capfd - Enable capturing of writes to file descriptors ``1`` and ``2`` and make - captured output available via ``capfd.readouterr()`` method calls - which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text`` - objects. + Enable text capturing of writes to file descriptors ``1`` and ``2``. + + The captured output is made available via ``capfd.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``text`` objects. capfdbinary - Enable capturing of write to file descriptors 1 and 2 and make - captured output available via ``capfdbinary.readouterr`` method calls - which return a ``(out, err)`` tuple. ``out`` and ``err`` will be - ``bytes`` objects. + Enable bytes capturing of writes to file descriptors ``1`` and ``2``. + + The captured output is made available via ``capfd.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``byte`` objects. doctest_namespace Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. pytestconfig diff --git a/doc/en/cache.rst b/doc/en/cache.rst index 89a1e2634..8baf88113 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -82,7 +82,7 @@ If you then run it with ``--lf``: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 50 items / 48 deselected / 2 selected run-last-failure: rerun previous 2 failures @@ -126,7 +126,7 @@ of ``FF`` and dots): =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 50 items run-last-failure: rerun previous 2 failures first @@ -218,8 +218,6 @@ If you run this command for the first time, you can see the print statement: def test_function(mydata): > assert mydata == 23 E assert 42 == 23 - E -42 - E +23 test_caching.py:17: AssertionError -------------------------- Captured stdout setup --------------------------- @@ -241,8 +239,6 @@ the cache and nothing will be printed: def test_function(mydata): > assert mydata == 23 E assert 42 == 23 - E -42 - E +23 test_caching.py:17: AssertionError 1 failed in 0.12 seconds @@ -262,7 +258,7 @@ You can always peek at the content of the cache using the =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project cachedir: $PYTHON_PREFIX/.pytest_cache ------------------------------- cache values ------------------------------- cache/lastfailed contains: diff --git a/doc/en/capture.rst b/doc/en/capture.rst index f62ec60ca..f0652aa26 100644 --- a/doc/en/capture.rst +++ b/doc/en/capture.rst @@ -71,7 +71,7 @@ of the failing function and hide the other one: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py .F [100%] diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 549ebb00f..db7eb14a4 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -72,7 +72,7 @@ then you can just invoke ``pytest`` without command line options: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + rootdir: /home/sweet/project, inifile: pytest.ini collected 1 item mymodule.py . [100%] diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 5ec57caed..d207ef7e2 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -35,7 +35,7 @@ You can then restrict a test run to only run tests marked with ``webtest``: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 4 items / 3 deselected / 1 selected test_server.py::test_send_http PASSED [100%] @@ -50,7 +50,7 @@ Or the inverse, running all tests except the webtest ones: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 4 items / 1 deselected / 3 selected test_server.py::test_something_quick PASSED [ 33%] @@ -72,7 +72,7 @@ tests based on their module, class, method, or function name: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 1 item test_server.py::TestClass::test_method PASSED [100%] @@ -87,7 +87,7 @@ You can also select on the class: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 1 item test_server.py::TestClass::test_method PASSED [100%] @@ -102,7 +102,7 @@ Or select multiple nodes: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 2 items test_server.py::TestClass::test_method PASSED [ 50%] @@ -142,7 +142,7 @@ select tests based on their names: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 4 items / 3 deselected / 1 selected test_server.py::test_send_http PASSED [100%] @@ -157,7 +157,7 @@ And you can also run all tests except the ones that match the keyword: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 4 items / 1 deselected / 3 selected test_server.py::test_something_quick PASSED [ 33%] @@ -174,7 +174,7 @@ Or to select "http" and "quick" tests: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 4 items / 2 deselected / 2 selected test_server.py::test_send_http PASSED [ 50%] @@ -370,7 +370,7 @@ the test needs: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_someenv.py s [100%] @@ -385,7 +385,7 @@ and here is one that specifies exactly the environment needed: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_someenv.py . [100%] @@ -555,12 +555,12 @@ then you will see two tests skipped and two executed tests as expected: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items test_plat.py s.s. [100%] ========================= short test summary info ========================== - SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux + SKIPPED [2] /home/sweet/project/conftest.py:12: cannot run on platform linux =================== 2 passed, 2 skipped in 0.12 seconds ==================== @@ -572,7 +572,7 @@ Note that if you specify a platform via the marker-command line option like this =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items / 3 deselected / 1 selected test_plat.py . [100%] @@ -626,7 +626,7 @@ We can now use the ``-m option`` to select one set: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items / 2 deselected / 2 selected test_module.py FF [100%] @@ -650,7 +650,7 @@ or to select both "event" and "interface" tests: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items / 1 deselected / 3 selected test_module.py FFF [100%] diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index bf7173ee5..f6d1e578e 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -31,7 +31,7 @@ now execute the test specification: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + rootdir: /home/sweet/project/nonpython collected 2 items test_simple.yml F. [100%] @@ -66,7 +66,7 @@ consulted when reporting in ``verbose`` mode: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + rootdir: /home/sweet/project/nonpython collecting ... collected 2 items test_simple.yml::hello FAILED [ 50%] @@ -90,9 +90,9 @@ interesting to just look at the collection tree: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + rootdir: /home/sweet/project/nonpython collected 2 items - + diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index b5d4693ad..1b9f657fd 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -146,7 +146,7 @@ objects, they are still using the default pytest representation: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 8 items @@ -205,7 +205,7 @@ this is a fully self-contained example which you can run with: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items test_scenarios.py .... [100%] @@ -220,7 +220,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items @@ -287,7 +287,7 @@ Let's first see how it looks like at collection time: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items @@ -353,7 +353,7 @@ The result of this test will be successful: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item @@ -411,8 +411,6 @@ argument sets to use for each test function. Let's run it: def test_equals(self, a, b): > assert a == b E assert 1 == 2 - E -1 - E +2 test_parametrize.py:18: AssertionError 1 failed, 2 passed in 0.12 seconds @@ -436,9 +434,9 @@ Running it results in some skips if we don't have all the python interpreters in .. code-block:: pytest . $ pytest -rs -q multipython.py - ...sss...sssssssss...sss... [100%] + ......sss......ssssssssssss [100%] ========================= short test summary info ========================== - SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.4' not found + SKIPPED [15] /home/sweet/project/CWD/multipython.py:30: 'python3.5' not found 12 passed, 15 skipped in 0.12 seconds Indirect parametrization of optional implementations/imports @@ -490,12 +488,12 @@ If you run this with reporting for skips enabled: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py .s [100%] ========================= short test summary info ========================== - SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:11: could not import 'opt2' + SKIPPED [1] /home/sweet/project/conftest.py:11: could not import 'opt2' =================== 1 passed, 1 skipped in 0.12 seconds ==================== @@ -548,7 +546,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 17 items / 14 deselected / 3 selected test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 02c12f6bc..40eb333b1 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -148,7 +148,7 @@ The test collection would look like this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + rootdir: /home/sweet/project, inifile: pytest.ini collected 2 items @@ -210,7 +210,7 @@ You can always peek at the collection tree without running tests like this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + rootdir: /home/sweet/project, inifile: pytest.ini collected 3 items @@ -285,7 +285,7 @@ file will be left out: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + rootdir: /home/sweet/project, inifile: pytest.ini collected 0 items ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 9fcc72ffe..2a296dc10 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -15,7 +15,7 @@ get on the terminal - we are working on that): =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR/assertion, inifile: + rootdir: /home/sweet/project/assertion collected 44 items failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] @@ -475,7 +475,7 @@ get on the terminal - we are working on that): > assert 1 == 0 E AssertionError - <0-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:201>:2: AssertionError + <0-codegen 'abc-123' /home/sweet/project/assertion/failure_demo.py:201>:2: AssertionError ____________________ TestMoreErrors.test_complex_error _____________________ self = diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 1c6cf36c9..a909cd74f 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -129,7 +129,7 @@ directory with the above conftest.py: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -190,7 +190,7 @@ and when running it will see a skipped "slow" test: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py .s [100%] @@ -207,7 +207,7 @@ Or run it including the ``slow`` marked test: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py .. [100%] @@ -351,7 +351,7 @@ which will add the string to the test header accordingly: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache project deps: mylib-1.1 - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -381,7 +381,7 @@ which will add info only when run with "--v": cachedir: $PYTHON_PREFIX/.pytest_cache info1: did you know that ... did you? - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -394,7 +394,7 @@ and nothing when run plainly: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -434,7 +434,7 @@ Now we can profile which test functions execute the slowest: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 3 items test_some_are_slow.py ... [100%] @@ -509,7 +509,7 @@ If we run this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 4 items test_step.py .Fx. [100%] @@ -593,7 +593,7 @@ We can run this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 7 items test_step.py .Fx. [ 57%] @@ -603,13 +603,13 @@ We can run this: ================================== ERRORS ================================== _______________________ ERROR at setup of test_root ________________________ - file $REGENDOC_TMPDIR/b/test_error.py, line 1 + file /home/sweet/project/b/test_error.py, line 1 def test_root(db): # no db here, will error out E fixture 'db' not found > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory > use 'pytest --fixtures [testpath]' for help on them. - $REGENDOC_TMPDIR/b/test_error.py:1 + /home/sweet/project/b/test_error.py:1 ================================= FAILURES ================================= ____________________ TestUserHandling.test_modification ____________________ @@ -707,7 +707,7 @@ and run them: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py FF [100%] @@ -811,7 +811,7 @@ and run it: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 3 items test_module.py Esetting up a test failed! test_module.py::test_setup_fails diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 390f8abcc..1de33054e 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -74,7 +74,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_smtpsimple.py F [100%] @@ -217,7 +217,7 @@ inspect what is going on and can now run the tests: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_module.py FF [100%] @@ -710,7 +710,7 @@ Running the above tests results in the following test IDs being used: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 10 items @@ -755,7 +755,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 3 items test_fixture_marks.py::test_data[0] PASSED [ 33%] @@ -800,7 +800,7 @@ Here we declare an ``app`` fixture which receives the previously defined =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 2 items test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] @@ -871,7 +871,7 @@ Let's run the tests in verbose mode and with looking at the print-output: =========================== 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 cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collecting ... collected 8 items test_module.py::test_0[1] SETUP otherarg 1 diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 222ae65ba..58b0cfca4 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -52,7 +52,7 @@ That’s it. You can now execute the test function: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_sample.py F [100%] diff --git a/doc/en/index.rst b/doc/en/index.rst index 000793d27..32d10040c 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -30,7 +30,7 @@ To execute it: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_sample.py F [100%] diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 70a35ac44..c9bd09d1a 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -58,7 +58,7 @@ them in turn: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 3 items test_expectation.py ..F [100%] @@ -125,7 +125,7 @@ Let's run this: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 3 items test_expectation.py ..x [100%] @@ -226,7 +226,7 @@ list: $ pytest -q -rs test_strings.py s [100%] ========================= short test summary info ========================== - SKIPPED [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1 + SKIPPED [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at /home/sweet/project/test_strings.py:1 1 skipped in 0.12 seconds Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index 96af8ee35..69d7940fc 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -335,7 +335,7 @@ Running it with the report-on-xfail option gives this output: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR/example, inifile: + rootdir: /home/sweet/project/example collected 7 items xfail_demo.py xxxxxxx [100%] diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index f16b9260c..8fbd1fe59 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -43,7 +43,7 @@ Running this would result in a passed test except for the last =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_tmp_path.py F [100%] @@ -110,7 +110,7 @@ Running this would result in a passed test except for the last =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_tmpdir.py F [100%] diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index 7eb92bf43..53ccef599 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -130,7 +130,7 @@ the ``self.db`` values in the traceback: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 2 items test_unittest_db.py FF [100%] diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 51511673a..d6850beda 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -204,7 +204,7 @@ Example: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 6 items test_example.py .FEsxX [100%] @@ -227,13 +227,13 @@ Example: test_example.py:14: AssertionError ========================= short test summary info ========================== - SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test + SKIPPED [1] /home/sweet/project/test_example.py:23: skipping this test XFAIL test_example.py::test_xfail reason: xfailing this test XPASS test_example.py::test_xpass always xfail ERROR test_example.py::test_error FAILED test_example.py::test_fail - 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds + = 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds = The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes". @@ -256,7 +256,7 @@ More than one character can be used, so for example to only see failed and skipp =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 6 items test_example.py .FEsxX [100%] @@ -280,8 +280,8 @@ More than one character can be used, so for example to only see failed and skipp test_example.py:14: AssertionError ========================= short test summary info ========================== FAILED test_example.py::test_fail - SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test - 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds + SKIPPED [1] /home/sweet/project/test_example.py:23: skipping this test + = 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds = Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had captured output: @@ -292,7 +292,7 @@ captured output: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 6 items test_example.py .FEsxX [100%] @@ -320,7 +320,7 @@ captured output: _________________________________ test_ok __________________________________ --------------------------- Captured stdout call --------------------------- ok - 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds + = 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds = .. _pdb-option: diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 11f73f43e..c47817c9a 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -26,14 +26,14 @@ Running pytest now produces this output: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: + rootdir: /home/sweet/project collected 1 item test_show_warnings.py . [100%] ============================= warnings summary ============================= test_show_warnings.py::test_one - $REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2 + /home/sweet/project/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2 warnings.warn(UserWarning("api v1, should use functions from v2")) -- Docs: https://docs.pytest.org/en/latest/warnings.html @@ -378,7 +378,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta ============================= warnings summary ============================= test_pytest_warnings.py:1 - $REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestWarning: cannot collect test class 'Test' because it has a __init__ constructor + /home/sweet/project/test_pytest_warnings.py:1: PytestWarning: cannot collect test class 'Test' because it has a __init__ constructor class Test: -- Docs: https://docs.pytest.org/en/latest/warnings.html diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index 39ee9ae63..e717431e6 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -433,14 +433,14 @@ additionally it is possible to copy examples for an example folder before runnin =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y cachedir: $PYTHON_PREFIX/.pytest_cache - rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + rootdir: /home/sweet/project, inifile: pytest.ini collected 2 items test_example.py .. [100%] ============================= warnings summary ============================= test_example.py::test_plugin - $REGENDOC_TMPDIR/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time + /home/sweet/project/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time testdir.copy_example("test_example.py") -- Docs: https://docs.pytest.org/en/latest/warnings.html diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 4afadc5a5..d474df4b9 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -482,9 +482,6 @@ class Testdir(object): name = request.function.__name__ self.tmpdir = tmpdir_factory.mktemp(name, numbered=True) self.test_tmproot = tmpdir_factory.mktemp("tmp-" + name, numbered=True) - os.environ["PYTEST_DEBUG_TEMPROOT"] = str(self.test_tmproot) - os.environ.pop("TOX_ENV_DIR", None) # Ensure that it is not used for caching. - os.environ.pop("PYTEST_ADDOPTS", None) # Do not use outer options. self.plugins = [] self._cwd_snapshot = CwdSnapshot() self._sys_path_snapshot = SysPathsSnapshot() @@ -497,6 +494,13 @@ class Testdir(object): elif method == "subprocess": self._runpytest_method = self.runpytest_subprocess + mp = self.monkeypatch = MonkeyPatch() + mp.setenv("PYTEST_DEBUG_TEMPROOT", str(self.test_tmproot)) + # Ensure no unexpected caching via tox. + mp.delenv("TOX_ENV_DIR", raising=False) + # Discard outer pytest options. + mp.delenv("PYTEST_ADDOPTS", raising=False) + def __repr__(self): return "" % (self.tmpdir,) @@ -514,7 +518,7 @@ class Testdir(object): self._sys_modules_snapshot.restore() self._sys_path_snapshot.restore() self._cwd_snapshot.restore() - os.environ.pop("PYTEST_DEBUG_TEMPROOT", None) + self.monkeypatch.undo() def __take_sys_modules_snapshot(self): # some zope modules used by twisted-related tests keep internal state @@ -805,11 +809,11 @@ class Testdir(object): """ finalizers = [] try: - # Do not load user config. - monkeypatch = MonkeyPatch() - monkeypatch.setenv("HOME", str(self.tmpdir)) - monkeypatch.setenv("USERPROFILE", str(self.tmpdir)) - finalizers.append(monkeypatch.undo) + # Do not load user config (during runs only). + mp_run = MonkeyPatch() + mp_run.setenv("HOME", str(self.tmpdir)) + mp_run.setenv("USERPROFILE", str(self.tmpdir)) + finalizers.append(mp_run.undo) # When running pytest inline any plugins active in the main test # process are already imported. So this disables the warning which diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 08167ec90..2e4877463 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -469,3 +469,16 @@ def test_linematcher_with_nonlist(): assert lm._getlines({}) == {} assert lm._getlines(set()) == set() + + +def test_pytester_addopts(request, monkeypatch): + monkeypatch.setenv("PYTEST_ADDOPTS", "--orig-unused") + + testdir = request.getfixturevalue("testdir") + + try: + assert "PYTEST_ADDOPTS" not in os.environ + finally: + testdir.finalize() + + assert os.environ["PYTEST_ADDOPTS"] == "--orig-unused" diff --git a/tox.ini b/tox.ini index d0dd95ea3..16984dd43 100644 --- a/tox.ini +++ b/tox.ini @@ -106,6 +106,7 @@ commands = # don't show hypothesis plugin info in docs, see #4602 pip uninstall hypothesis -y rm -rf /tmp/doc-exec* + rm -rf {envdir}/.pytest_cache make regen [testenv:jython]