Merge master into features

This commit is contained in:
Daniel Hahler 2019-10-18 17:51:42 +02:00
commit 0976e2f50d
19 changed files with 97 additions and 18 deletions

View File

@ -35,7 +35,9 @@ jobs:
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37 - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
# Full run of latest supported version, without xdist. # Full run of latest supported version, without xdist.
- env: TOXENV=py37 # Coverage for:
# - test_sys_breakpoint_interception (via pexpect).
- env: TOXENV=py37-pexpect PYTEST_COVERAGE=1
python: '3.7' python: '3.7'
# Coverage tracking is slow with pypy, skip it. # Coverage tracking is slow with pypy, skip it.
@ -54,9 +56,6 @@ jobs:
- env: TOXENV=py37-lsof-oldattrs-numpy-twisted-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS= - env: TOXENV=py37-lsof-oldattrs-numpy-twisted-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
# Specialized factors for py37. # Specialized factors for py37.
# Coverage for:
# - test_sys_breakpoint_interception (via pexpect).
- env: TOXENV=py37-pexpect PYTEST_COVERAGE=1
- env: TOXENV=py37-pluggymaster-xdist - env: TOXENV=py37-pluggymaster-xdist
- env: TOXENV=py37-freeze - env: TOXENV=py37-freeze

View File

@ -27,6 +27,33 @@ Bug Fixes
- `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. - `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
pytest 4.6.6 (2019-10-11)
=========================
Bug Fixes
---------
- `#5523 <https://github.com/pytest-dev/pytest/issues/5523>`_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
- `#5537 <https://github.com/pytest-dev/pytest/issues/5537>`_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
standard library on Python 3.8+.
- `#5806 <https://github.com/pytest-dev/pytest/issues/5806>`_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
- `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
Trivial/Internal Changes
------------------------
- `#5801 <https://github.com/pytest-dev/pytest/issues/5801>`_: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.
pytest 5.2.0 (2019-09-28) pytest 5.2.0 (2019-09-28)
========================= =========================
@ -214,9 +241,6 @@ Bug Fixes
- `#5477 <https://github.com/pytest-dev/pytest/issues/5477>`_: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element. - `#5477 <https://github.com/pytest-dev/pytest/issues/5477>`_: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
- `#5523 <https://github.com/pytest-dev/pytest/issues/5523>`_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
- `#5524 <https://github.com/pytest-dev/pytest/issues/5524>`_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only, - `#5524 <https://github.com/pytest-dev/pytest/issues/5524>`_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
which could lead to pytest crashing when executed a second time with the ``--basetemp`` option. which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.

View File

@ -0,0 +1 @@
Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).

View File

@ -29,7 +29,6 @@ Thanks to all who contributed to this release, among them:
* Michael Goerz * Michael Goerz
* Ran Benita * Ran Benita
* Tomáš Chvátal * Tomáš Chvátal
* aklajnert
Happy testing, Happy testing,

View File

@ -156,6 +156,8 @@ pytest also introduces new options:
a string! This means that it may not be appropriate to enable globally in a string! This means that it may not be appropriate to enable globally in
``doctest_optionflags`` in your configuration file. ``doctest_optionflags`` in your configuration file.
.. versionadded:: 5.1
Continue on failure Continue on failure
------------------- -------------------

View File

@ -301,9 +301,13 @@ are finalized when the last test of a *package* finishes.
Use this new feature sparingly and please make sure to report any issues you find. Use this new feature sparingly and please make sure to report any issues you find.
.. _dynamic scope:
Dynamic scope Dynamic scope
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
.. versionadded:: 5.2
In some cases, you might want to change the scope of the fixture without changing the code. In some cases, you might want to change the scope of the fixture without changing the code.
To do that, pass a callable to ``scope``. The callable must return a string with a valid scope To do that, pass a callable to ``scope``. The callable must return a string with a valid scope
and will be executed only once - during the fixture definition. It will be called with two and will be executed only once - during the fixture definition. It will be called with two

View File

@ -38,7 +38,8 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref:
* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment * `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
* `pylib <https://pylib.readthedocs.io/en/stable/>`_ cross-platform path, IO, dynamic code library * `pylib <https://pylib.readthedocs.io/en/stable/>`_ cross-platform path, IO, dynamic code library
* `bbfreeze <https://pypi.org/project/bbfreeze/>`_ create standalone executables from Python scripts * `bbfreeze <https://pypi.org/project/bbfreeze/>`_ create standalone executables from Python scripts
* `pdb++ <http://bitbucket.org/antocuni/pdb>`_ a fancier version of PDB * `pdb++ <https://github.com/pdbpp/pdbpp>`_ a fancier version of PDB
* `pudb <https://github.com/inducer/pudb>`_ full-screen console debugger for python
* `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem * `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem
* `waskr <http://code.google.com/p/waskr/>`_ WSGI Stats Middleware * `waskr <http://code.google.com/p/waskr/>`_ WSGI Stats Middleware
* `guachi <http://code.google.com/p/guachi/>`_ global persistent configs for Python modules * `guachi <http://code.google.com/p/guachi/>`_ global persistent configs for Python modules

View File

@ -24,3 +24,8 @@ branch will continue to exist so the community itself can contribute patches. Th
be happy to accept those patches and make new ``4.6`` releases **until mid-2020**. be happy to accept those patches and make new ``4.6`` releases **until mid-2020**.
.. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires .. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
Technical Aspects
-----------------
The technical aspects of the Python 2.7 and 3.4 support plan (such as when releases will occurr, how to backport fixes, etc) is described in issue `#5275 <https://github.com/pytest-dev/pytest/issues/5275>`__.

View File

@ -2,10 +2,6 @@
Talks and Tutorials Talks and Tutorials
========================== ==========================
.. sidebar:: Next Open Trainings
- `3 day hands-on workshop covering pytest, tox and devpi: "Professional Testing with Python" <https://python-academy.com/courses/specialtopics/python_course_testing.html>`_ (English), October 21 - 23, 2019, Leipzig, Germany.
.. _`funcargs`: funcargs.html .. _`funcargs`: funcargs.html
Books Books

View File

@ -718,6 +718,11 @@ for example ``-x`` if you only want to send one particular failure.
Currently only pasting to the http://bpaste.net service is implemented. Currently only pasting to the http://bpaste.net service is implemented.
.. versionchanged:: 5.2
If creating the URL fails for any reason, a warning is generated instead of failing the
entire test suite.
Early loading plugins Early loading plugins
--------------------- ---------------------

View File

@ -13,5 +13,6 @@ fi
python -m coverage combine python -m coverage combine
python -m coverage xml python -m coverage xml
python -m coverage report -m python -m coverage report -m
curl -S -L --retry 6 -s https://codecov.io/bash -o codecov-upload.sh # Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
bash codecov-upload.sh -Z -X fix -f coverage.xml bash codecov-upload.sh -Z -X fix -f coverage.xml

View File

@ -663,6 +663,8 @@ class Config:
class InvocationParams: class InvocationParams:
"""Holds parameters passed during ``pytest.main()`` """Holds parameters passed during ``pytest.main()``
.. versionadded:: 5.1
.. note:: .. note::
Currently the environment variable PYTEST_ADDOPTS is also handled by Currently the environment variable PYTEST_ADDOPTS is also handled by

View File

@ -1088,9 +1088,13 @@ def fixture(
:arg scope: the scope for which this fixture is shared, one of :arg scope: the scope for which this fixture is shared, one of
``"function"`` (default), ``"class"``, ``"module"``, ``"function"`` (default), ``"class"``, ``"module"``,
``"package"`` or ``"session"``. ``"package"`` or ``"session"`` (``"package"`` is considered **experimental**
at this time).
``"package"`` is considered **experimental** at this time. This parameter may also be a callable which receives ``(fixture_name, config)``
as parameters, and must return a ``str`` with one of the values mentioned above.
See :ref:`dynamic scope` in the docs for more information.
:arg params: an optional list of parameters which will cause multiple :arg params: an optional list of parameters which will cause multiple
invocations of the fixture function and all of the tests invocations of the fixture function and all of the tests
@ -1113,6 +1117,9 @@ def fixture(
``fixture_<fixturename>`` and then use ``fixture_<fixturename>`` and then use
``@pytest.fixture(name='<fixturename>')``. ``@pytest.fixture(name='<fixturename>')``.
""" """
if params is not None:
params = list(params)
fixture_function, arguments = _parse_fixture_args( fixture_function, arguments = _parse_fixture_args(
callable_or_scope, callable_or_scope,
*args, *args,
@ -1134,8 +1141,6 @@ def fixture(
fixture_function fixture_function
) )
if params is not None and not isinstance(params, (list, tuple)):
params = list(params)
return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name) return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)

View File

@ -488,6 +488,8 @@ def pytest_assertion_pass(item, lineno, orig, expl):
""" """
**(Experimental)** **(Experimental)**
.. versionadded:: 5.0
Hook called whenever an assertion *passes*. Hook called whenever an assertion *passes*.
Use this hook to do some processing after a passing assertion. Use this hook to do some processing after a passing assertion.

View File

@ -356,6 +356,7 @@ def caplog(request):
Captured logs are available through the following properties/methods:: Captured logs are available through the following properties/methods::
* caplog.messages -> list of format-interpolated log messages
* caplog.text -> string containing formatted log output * caplog.text -> string containing formatted log output
* caplog.records -> list of logging.LogRecord instances * caplog.records -> list of logging.LogRecord instances
* caplog.record_tuples -> list of (logger_name, level, message) tuples * caplog.record_tuples -> list of (logger_name, level, message) tuples

View File

@ -20,6 +20,8 @@ from _pytest.runner import collect_one_node
class ExitCode(enum.IntEnum): class ExitCode(enum.IntEnum):
""" """
.. versionadded:: 5.0
Encodes the valid exit codes by pytest. Encodes the valid exit codes by pytest.
Currently users and plugins may supply other exit codes as well. Currently users and plugins may supply other exit codes as well.

View File

@ -4187,3 +4187,23 @@ def test_indirect_fixture_does_not_break_scope(testdir):
) )
result = testdir.runpytest() result = testdir.runpytest()
result.assert_outcomes(passed=7) result.assert_outcomes(passed=7)
def test_fixture_parametrization_nparray(testdir):
pytest.importorskip("numpy")
testdir.makepyfile(
"""
from numpy import linspace
from pytest import fixture
@fixture(params=linspace(1, 10, 10))
def value(request):
return request.param
def test_bug(value):
assert value == value
"""
)
result = testdir.runpytest()
result.assert_outcomes(passed=10)

View File

@ -17,6 +17,14 @@ else:
_ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "") _ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "")
@pytest.fixture(autouse=True)
def pdb_env(request):
if "testdir" in request.fixturenames:
# Disable pdb++ with inner tests.
testdir = request.getfixturevalue("testdir")
testdir._env_run_update["PDBPP_HIJACK_PDB"] = "0"
def runpdb_and_get_report(testdir, source): def runpdb_and_get_report(testdir, source):
p = testdir.makepyfile(source) p = testdir.makepyfile(source)
result = testdir.runpytest_inprocess("--pdb", p) result = testdir.runpytest_inprocess("--pdb", p)

View File

@ -142,6 +142,8 @@ filterwarnings =
error error
default:Using or importing the ABCs:DeprecationWarning:unittest2.* default:Using or importing the ABCs:DeprecationWarning:unittest2.*
ignore:Module already imported so cannot be rewritten:pytest.PytestWarning ignore:Module already imported so cannot be rewritten:pytest.PytestWarning
# https://github.com/pytest-dev/pytest/issues/5974
default:\(rm_rf\) error removing.*:pytest.PytestWarning
# produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8). # produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8).
ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest)) ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest))
# produced by pytest-xdist # produced by pytest-xdist