Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
126896f
Add option to disable plugin auto-loading
Aug 6, 2018
5f97711
Merge pull request #3787 from hsoft/no-plugin-autoload
nicoddemus Aug 9, 2018
c64a8c9
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 18, 2018
a6cdd0d
Merge pull request #3831 from nicoddemus/merge-master-into-features
nicoddemus Aug 18, 2018
539a22c
Added support for xfailed and xpassed outcomes to the ``pytester.RunR…
wimglenn Aug 20, 2018
044d2b8
Merge pull request #3838 from wimglenn/runresult_xfail
nicoddemus Aug 20, 2018
93f7832
Add the progress_display_mode ini option
jeffreyrack Aug 24, 2018
5fefc48
Fixing pre-commit hooks
jeffreyrack Aug 24, 2018
5e260c4
Fixing changelog file.
jeffreyrack Aug 26, 2018
dda5e5e
Fixing backticks in changelog file.
jeffreyrack Aug 26, 2018
325319d
Fixing xdist test to properly configure an ini file.
jeffreyrack Aug 26, 2018
2a917a5
Removing accidental change to test
jeffreyrack Aug 26, 2018
2f2d586
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 26, 2018
80eef29
Merge pull request #3884 from nicoddemus/merge-master-into-features
nicoddemus Aug 26, 2018
8f4685e
Move count display style to be part of console_output_style, fixed te…
jeffreyrack Aug 27, 2018
23295e1
Fix docs linting
nicoddemus Aug 27, 2018
4b94760
Removed spacing in count display.
jeffreyrack Aug 28, 2018
a605ad4
Merge pull request #3880 from jeffreyrack/3829-progress_display_mode
nicoddemus Aug 28, 2018
3035b27
T3853:removed needless message printed with --failed-first,--last-fai…
dhirensr Aug 30, 2018
ade01b1
T3853:Added changelog file
dhirensr Aug 30, 2018
0183d46
Improve CHANGELOG a bit
nicoddemus Aug 30, 2018
84a033f
Remove extra newline
nicoddemus Aug 30, 2018
64f0068
Merge pull request #3912 from dhirensr/needless_message
nicoddemus Aug 30, 2018
11e591e
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 30, 2018
2256f2f
Remove test which is no longer required and improve test_lf_and_ff_pr…
nicoddemus Aug 31, 2018
01df368
Merge pull request #3914 from nicoddemus/merge-master-into-features
RonnyPfannschmidt Aug 31, 2018
b01704c
Fix exit code for command line errors
crazymerlyn Sep 2, 2018
10f21b4
Remove assert for "reprec" because this is no longer set on the plugi…
nicoddemus Aug 25, 2018
ffd47ce
Implement new pytest_warning_captured hook
nicoddemus Aug 25, 2018
3fcc4cd
Make terminal capture pytest_warning_capture
nicoddemus Aug 26, 2018
51e32cf
Remove Python 2.6 specific warning
nicoddemus Aug 26, 2018
1a9d913
Capture and display warnings during collection
nicoddemus Aug 26, 2018
0100f61
Start the laywork to capture standard warnings
nicoddemus Aug 29, 2018
8e4501e
Use std_warn for warning about applying marks directly to parameters
nicoddemus Aug 31, 2018
0c8dbdc
Fix existing tests now that we are using standard warnings
nicoddemus Sep 1, 2018
78ac7d9
Deprecate Config.warn and Node.warn, replaced by standard warnings
nicoddemus Sep 2, 2018
19a01c9
Make PytestWarning and RemovedInPytest4Warning part of the public API
nicoddemus Sep 3, 2018
208dd3a
Add docs for internal warnings and introduce PytestDeprecationWarning
nicoddemus Sep 3, 2018
7e13593
Add CHANGELOG entries for #2452
nicoddemus Sep 3, 2018
9965ed8
Show deprecation warnings by default if no other filters are configured
nicoddemus Sep 3, 2018
60499d2
Add test to ensure that users can suppress internal warnings
nicoddemus Sep 3, 2018
0fffa6b
Implement hack to issue warnings during config
nicoddemus Sep 3, 2018
56d4141
Remove nodeid from messages for warnings generated by standard warnings
nicoddemus Sep 3, 2018
b818314
Improve docs for warnings capture and PEP-0506 remarks
nicoddemus Sep 4, 2018
8ce3aea
Move PytestExerimentalApiWarning to warning_types
nicoddemus Sep 4, 2018
415a62e
Fix typo in PytestExperimentalApiWarning
nicoddemus Sep 4, 2018
c304998
Remove commented out code
nicoddemus Sep 4, 2018
e9417be
Add comment about deprecation warnings being shown by default
nicoddemus Sep 4, 2018
016f8f1
Improve get_fslocation_from_item's docstring
nicoddemus Sep 4, 2018
29bfa5e
Merge pull request #3925 from crazymerlyn/fix-exit-code
nicoddemus Sep 4, 2018
615c671
Connect string literals
nicoddemus Sep 4, 2018
9ae0a3c
Do not trigger warning about tuples being always True if the tuple ha…
nicoddemus Sep 4, 2018
284a2d1
Move warnings import to top level
nicoddemus Sep 4, 2018
b42518a
Change std_warn to receive a single warning instance, addressed revie…
nicoddemus Sep 4, 2018
022c58b
Revert pytest_terminal_summary(tryfirst) in warnings module as this b…
nicoddemus Sep 4, 2018
d3f72ca
Fix linting for warnings.rst
nicoddemus Sep 4, 2018
f1cfd10
Handle cache warnings in tests
nicoddemus Sep 4, 2018
a054aa4
Issue assert rewrite warning if tuple >=1 as suggested in review
nicoddemus Sep 4, 2018
5ef5126
Fix reference to PytestWarning in warningsfilter mark
nicoddemus Sep 4, 2018
47bf58d
Make Node.warn support two forms, new and deprecated
nicoddemus Sep 4, 2018
438f7a1
Add "setup", "call" and "teardown" values to "when" parameter of pyte…
nicoddemus Sep 4, 2018
3db76cc
Fix Cache.warn function to issue a "config" warning
nicoddemus Sep 4, 2018
d3ca739
Use explicit instances when calling warnings.warn_explicit
nicoddemus Sep 4, 2018
b7560a8
Keep backward compatibility for code as kw in Node.warn
nicoddemus Sep 4, 2018
6d497f2
Fix stacklevel for warning about Metafunc.addcall
nicoddemus Sep 4, 2018
5a52aca
Make config no longer optional in parametrize id functions
nicoddemus Sep 4, 2018
2e0a7cf
Revert to having just "runtest" as "when" parameter of the pytest_war…
nicoddemus Sep 4, 2018
4592def
Improve test_rewarn_functional
nicoddemus Sep 4, 2018
adc9ed8
Fix test_idval_hypothesis
nicoddemus Sep 4, 2018
f42b501
Make code_or_warning parameter private for backward-compatibility
nicoddemus Sep 4, 2018
ddb3084
Make sure warn is called in test_parameterset_extractfrom
nicoddemus Sep 5, 2018
f63c683
No longer escape regex in pytest.mark.filterwarnings
nicoddemus Sep 5, 2018
531b76a
Merge pull request #3931 from nicoddemus/internal-warnings
nicoddemus Sep 5, 2018
6e453ed
merge from master
RonnyPfannschmidt Sep 5, 2018
2e3acd0
Preparing release version 3.8.0
RonnyPfannschmidt Sep 5, 2018
71cf29f
manually restore parametrize docs to run regendoc later on
RonnyPfannschmidt Sep 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Christian Boelsen
Christian Theunert
Christian Tismer
Christopher Gilling
CrazyMerlyn
Cyrus Maden
Dhiren Serai
Daniel Grana
Expand Down Expand Up @@ -212,10 +213,12 @@ Vasily Kuznetsov
Victor Maryama
Victor Uriarte
Vidar T. Fauske
Virgil Dupras
Vitaly Lashmanov
Vlad Dragos
Wil Cooley
William Lee
Wim Glenn
Wouter van Ackooy
Xuan Luong
Xuecong Liao
Expand Down
84 changes: 84 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,90 @@ with advance notice in the **Deprecations** section of releases.

.. towncrier release notes start

pytest 3.8.0 (2018-09-05)
=========================

Deprecations and Removals
-------------------------

- `#2452 <https://github.com/pytest-dev/pytest/issues/2452>`_: ``Config.warn`` has been deprecated, it should be replaced by calls to the standard ``warnings.warn``.

``Node.warn`` now supports two signatures:

* ``node.warn(PytestWarning("some message"))``: is now the recommended way to call this function. The warning
instance must be a ``PytestWarning`` or subclass instance.

* ``node.warn("CI", "some message")``: this code/message form is now deprecated and should be converted to
the warning instance form above.

``RemovedInPytest4Warning`` and ``PytestExperimentalApiWarning`` are now part of the public API and should be accessed
using ``pytest.RemovedInPytest4Warning`` and ``pytest.PytestExperimentalApiWarning``.


Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to consider splitting deprecations and removals

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm good point

- `#3936 <https://github.com/pytest-dev/pytest/issues/3936>`_: ``@pytest.mark.filterwarnings`` second parameter is no longer regex-escaped,
making it possible to actually use regular expressions to check the warning message.

**Note**: regex-escaping the match string was an implementation oversight that might break test suites which depend
on the old behavior.



Features
--------

- `#2452 <https://github.com/pytest-dev/pytest/issues/2452>`_: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use
the standard warnings filters to manage those warnings. This introduces ``PytestWarning``,
``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API.

Consult `the documentation <https://docs.pytest.org/en/latest/warnings.html#internal-pytest-warnings>`_ for more info.


- `#2908 <https://github.com/pytest-dev/pytest/issues/2908>`_: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
configured. This makes pytest more compliant with
`PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_. See
`the docs <https://docs.pytest.org/en/latest/warnings.html#deprecationwarning-and-pendingdeprecationwarning>`_ for
more info.


- `#3784 <https://github.com/pytest-dev/pytest/issues/3784>`_: Add option to disable plugin auto-loading.


- `#3829 <https://github.com/pytest-dev/pytest/issues/3829>`_: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.


- `#3837 <https://github.com/pytest-dev/pytest/issues/3837>`_: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.



Bug Fixes
---------

- `#3911 <https://github.com/pytest-dev/pytest/issues/3911>`_: Terminal writer now takes into account unicode character width when writing out progress.


- `#3913 <https://github.com/pytest-dev/pytest/issues/3913>`_: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.


- `#3918 <https://github.com/pytest-dev/pytest/issues/3918>`_: Improve performance of assertion rewriting.



Improved Documentation
----------------------

- `#3566 <https://github.com/pytest-dev/pytest/issues/3566>`_: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.


- `#3907 <https://github.com/pytest-dev/pytest/issues/3907>`_: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.



Trivial/Internal Changes
------------------------

- `#3853 <https://github.com/pytest-dev/pytest/issues/3853>`_: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.


pytest 3.7.4 (2018-08-29)
=========================

Expand Down
1 change: 1 addition & 0 deletions changelog/3251.feture.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warnings are now captured and displayed during test collection.
1 change: 0 additions & 1 deletion changelog/3566.doc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3907.doc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3911.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3918.bugfix.rst

This file was deleted.

1 change: 1 addition & 0 deletions doc/en/announce/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2


release-3.8.0
release-3.7.4
release-3.7.3
release-3.7.2
Expand Down
40 changes: 40 additions & 0 deletions doc/en/announce/release-3.8.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
pytest-3.8.0
=======================================

The pytest team is proud to announce the 3.8.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
* Bruno Oliveira
* CrazyMerlyn
* Daniel Hahler
* Fabio Zadrozny
* Jeffrey Rackauckas
* Jiri Kuncar
* Ronny Pfannschmidt
* Steve Piercy
* Virgil Dupras
* dhirensr
* hoefling
* wim glenn


Happy testing,
The Pytest Development Team
36 changes: 25 additions & 11 deletions doc/en/example/pythoncollection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,32 @@ Finding out what is collected
You can always peek at the collection tree without running tests like this::

. $ pytest --collect-only pythoncollection.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini
collected 3 items
<Module 'CWD/pythoncollection.py'>
<Function 'test_function'>
<Class 'TestClass'>
<Instance '()'>
<Function 'test_method'>
<Function 'test_anothermethod'>
Traceback (most recent call last):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is incorrect, probably some update to regendocs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea off-hand, its the only hunk in that file, i'll revert that file and sort it out later

File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 381, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('$REGENDOC_TMPDIR/CWD/pythoncollection.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 381, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('$REGENDOC_TMPDIR/CWD')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 412, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('$REGENDOC_TMPDIR/CWD/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 418, in _importconftest
mod = conftestpath.pyimport()
File "$PYTHON_PREFIX/lib/python3.6/site-packages/py/_path/local.py", line 686, in pyimport
raise self.ImportMismatchError(modname, modfile, self)
py._path.local.LocalPath.ImportMismatchError: ('conftest', '$PWD/example/conftest.py', local('$REGENDOC_TMPDIR/CWD/conftest.py'))
ERROR: could not load $REGENDOC_TMPDIR/CWD/conftest.py

======================= no tests ran in 0.12 seconds =======================

.. _customizing-test-collection:

Expand Down
6 changes: 3 additions & 3 deletions doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ get on the terminal - we are working on that)::

failure_demo.py:261: AssertionError
============================= warnings summary =============================
<undetermined location>
Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0.
Please use Metafunc.parametrize instead.
$REGENDOC_TMPDIR/assertion/failure_demo.py:24: RemovedInPytest4Warning: Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0.
Please use Metafunc.parametrize instead.
metafunc.addcall(funcargs=dict(param1=3, param2=6))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================== 42 failed, 1 warnings in 0.12 seconds ===================
8 changes: 8 additions & 0 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ Session related reporting hooks:
.. autofunction:: pytest_terminal_summary
.. autofunction:: pytest_fixture_setup
.. autofunction:: pytest_fixture_post_finalizer
.. autofunction:: pytest_logwarning
.. autofunction:: pytest_warning_captured

And here is the central hook for reporting about
test execution:
Expand Down Expand Up @@ -866,6 +868,11 @@ Contains comma-separated list of modules that should be loaded as plugins:

export PYTEST_PLUGINS=mymodule.plugin,xdist

PYTEST_DISABLE_PLUGIN_AUTOLOAD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When set, disables plugin auto-loading through setuptools entrypoints. Only explicitly specified plugins will be
loaded.

PYTEST_CURRENT_TEST
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -935,6 +942,7 @@ passed multiple times. The expected format is ``name=value``. For example::

* ``classic``: classic pytest output.
* ``progress``: like classic pytest output, but with a progress indicator.
* ``count``: like progress, but shows progress as the number of tests completed instead of a percent.

The default is ``progress``, but you can fallback to ``classic`` if you prefer or
the new mode is causing unexpected problems:
Expand Down
47 changes: 26 additions & 21 deletions doc/en/skipping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,27 +324,32 @@ Here is a simple test file with the several usages:
Running it with the report-on-xfail option gives this output::

example $ pytest -rx xfail_demo.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR/example, inifile:
collected 7 items

xfail_demo.py xxxxxxx [100%]
========================= short test summary info ==========================
XFAIL xfail_demo.py::test_hello
XFAIL xfail_demo.py::test_hello2
reason: [NOTRUN]
XFAIL xfail_demo.py::test_hello3
condition: hasattr(os, 'sep')
XFAIL xfail_demo.py::test_hello4
bug 110
XFAIL xfail_demo.py::test_hello5
condition: pytest.__version__[0] != "17"
XFAIL xfail_demo.py::test_hello6
reason: reason
XFAIL xfail_demo.py::test_hello7

======================== 7 xfailed in 0.12 seconds =========================
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 381, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('$REGENDOC_TMPDIR/example/xfail_demo.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 381, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('$REGENDOC_TMPDIR/example')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 412, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('$REGENDOC_TMPDIR/example/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "$PYTHON_PREFIX/lib/python3.6/site-packages/_pytest/config/__init__.py", line 418, in _importconftest
mod = conftestpath.pyimport()
File "$PYTHON_PREFIX/lib/python3.6/site-packages/py/_path/local.py", line 686, in pyimport
raise self.ImportMismatchError(modname, modfile, self)
py._path.local.LocalPath.ImportMismatchError: ('conftest', '$PWD/example/conftest.py', local('$REGENDOC_TMPDIR/example/conftest.py'))
ERROR: could not load $REGENDOC_TMPDIR/example/conftest.py


.. _`skip/xfail with parametrize`:

Expand Down
19 changes: 10 additions & 9 deletions doc/en/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,12 @@ making it easy in large test suites to get a clear picture of all failures, skip
Example::

$ pytest -ra
======================== test session starts ========================
...
====================== short test summary info ======================
FAIL summary\test_foo.py::test_1
SKIP [1] summary\test_foo.py:12: not supported in this platform
XPASS summary\test_bar.py::test_4 flaky

===== 1 failed, 1 passed, 1 skipped, 1 xpassed in 0.08 seconds ======
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 0 items

======================= no tests ran in 0.12 seconds =======================

The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes".

Expand All @@ -179,8 +176,12 @@ Here is the full list of available characters that can be used:
More than one character can be used, so for example to only see failed and skipped tests, you can execute::

$ pytest -rfs
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 0 items


======================= no tests ran in 0.12 seconds =======================

.. _pdb-option:

Expand Down
Loading