Skip to content

Commit

Permalink
Merge pull request #5923 from nicoddemus/mm
Browse files Browse the repository at this point in the history
Merge master into features
  • Loading branch information
blueyed committed Oct 6, 2019
2 parents c1361b4 + 74aed6e commit b847d57
Show file tree
Hide file tree
Showing 30 changed files with 195 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ jobs:
# - pytester's LsofFdLeakChecker
# - TestArgComplete (linux only)
# - numpy
# - old attrs
# Empty PYTEST_ADDOPTS to run this non-verbose.
- env: TOXENV=py37-lsof-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.
# Coverage for:
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,54 @@ with advance notice in the **Deprecations** section of releases.
.. towncrier release notes start
pytest 5.2.1 (2019-10-06)
=========================

Bug Fixes
---------

- `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.


pytest 5.2.0 (2019-09-28)
=========================

Deprecations
------------

- `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them
as a keyword argument instead.



Features
--------

- `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives
the fixture name and the ``config`` object as keyword-only parameters.
See `the docs <https://docs.pytest.org/en/latest/fixture.html#dynamic-scope>`__ for more information.


- `#5764 <https://github.com/pytest-dev/pytest/issues/5764>`_: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run



Bug Fixes
---------

- `#5806 <https://github.com/pytest-dev/pytest/issues/5806>`_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".


- `#5884 <https://github.com/pytest-dev/pytest/issues/5884>`_: Fix ``--setup-only`` and ``--setup-show`` for custom pytest items.



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

- `#5056 <https://github.com/pytest-dev/pytest/issues/5056>`_: The HelpFormatter uses ``py.io.get_terminal_width`` for better width detection.


pytest 5.1.3 (2019-09-18)
=========================

Expand Down
2 changes: 0 additions & 2 deletions changelog/1682.deprecation.rst

This file was deleted.

3 changes: 0 additions & 3 deletions changelog/1682.feature.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/5056.trivial.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/5764.feature.rst

This file was deleted.

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

This file was deleted.

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


release-5.2.1
release-5.2.0
release-5.1.3
release-5.1.2
release-5.1.1
Expand Down
36 changes: 36 additions & 0 deletions doc/en/announce/release-5.2.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pytest-5.2.0
=======================================

The pytest team is proud to announce the 5.2.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:

* Andrzej Klajnert
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* James Cooke
* Michael Goerz
* Ran Benita
* Tomáš Chvátal
* aklajnert


Happy testing,
The Pytest Development Team
23 changes: 23 additions & 0 deletions doc/en/announce/release-5.2.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pytest-5.2.1
=======================================

pytest 5.2.1 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

pip install --upgrade pytest

The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Anthony Sottile
* Bruno Oliveira
* Florian Bruhin
* Hynek Schlawack
* Kevin J. Foley
* tadashigaki


Happy testing,
The pytest Development Team
5 changes: 4 additions & 1 deletion doc/en/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ progress output, you can write it into a configuration file:
.. code-block:: ini
# content of pytest.ini or tox.ini
# setup.cfg files should use [tool:pytest] section instead
[pytest]
addopts = -ra -q
# content of setup.cfg
[tool:pytest]
addopts = -ra -q
Alternatively, you can set a ``PYTEST_ADDOPTS`` environment variable to add command
line options while the environment is in use:

Expand Down
4 changes: 2 additions & 2 deletions doc/en/example/parametrize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,10 @@ Running it results in some skips if we don't have all the python interpreters in
.. code-block:: pytest
. $ pytest -rs -q multipython.py
ssssssssssss...ssssssssssss [100%]
ssssssssssssssssssssssss... [100%]
========================= short test summary info ==========================
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.7' not found
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.6' not found
3 passed, 24 skipped in 0.12s
Indirect parametrization of optional implementations/imports
Expand Down
4 changes: 2 additions & 2 deletions doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
items = [1, 2, 3]
print("items is {!r}".format(items))
> a, b = items.pop()
E TypeError: 'int' object is not iterable
E TypeError: cannot unpack non-iterable int object
failure_demo.py:181: TypeError
--------------------------- Captured stdout call ---------------------------
Expand Down Expand Up @@ -516,7 +516,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
def test_z2_type_error(self):
items = 3
> a, b = items
E TypeError: 'int' object is not iterable
E TypeError: cannot unpack non-iterable int object
failure_demo.py:222: TypeError
______________________ TestMoreErrors.test_startswith ______________________
Expand Down
2 changes: 1 addition & 1 deletion doc/en/example/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ Now we can profile which test functions execute the slowest:
========================= slowest 3 test durations =========================
0.30s call test_some_are_slow.py::test_funcslow2
0.21s call test_some_are_slow.py::test_funcslow1
0.20s call test_some_are_slow.py::test_funcslow1
0.10s call test_some_are_slow.py::test_funcfast
============================ 3 passed in 0.12s =============================
Expand Down
2 changes: 1 addition & 1 deletion doc/en/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Install ``pytest``
.. code-block:: bash
$ pytest --version
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.7/site-packages/pytest.py
.. _`simpletest`:

Expand Down
2 changes: 1 addition & 1 deletion doc/en/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ the records for the ``setup`` and ``call`` stages during teardown like so:
yield window
for when in ("setup", "call"):
messages = [
x.message for x in caplog.get_records(when) if x.level == logging.WARNING
x.message for x in caplog.get_records(when) if x.levelno == logging.WARNING
]
if messages:
pytest.fail(
Expand Down
2 changes: 1 addition & 1 deletion doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ passed multiple times. The expected format is ``name=value``. For example::
[pytest]
addopts = --maxfail=2 -rf # exit after 2 failures, report fail info
issuing ``pytest test_hello.py`` actually means::
issuing ``pytest test_hello.py`` actually means:

.. code-block:: bash
Expand Down
3 changes: 2 additions & 1 deletion scripts/report-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ fi
python -m coverage combine
python -m coverage xml
python -m coverage report -m
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml
curl -S -L --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
bash codecov-upload.sh -Z -X fix -f coverage.xml
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
INSTALL_REQUIRES = [
"py>=1.5.0",
"packaging",
"attrs>=17.4.0",
"attrs>=17.4.0", # should match oldattrs tox env.
"more-itertools>=4.0.0",
"atomicwrites>=1.0",
'pathlib2>=2.2.0;python_version<"3.6"',
Expand Down
5 changes: 4 additions & 1 deletion src/_pytest/assertion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import _pytest._code
from _pytest import outcomes
from _pytest._io.saferepr import saferepr
from _pytest.compat import ATTRS_EQ_FIELD

# The _reprcompare attribute on the util module is used by the new assertion
# interpretation code and assertion rewriter to detect this plugin was
Expand Down Expand Up @@ -375,7 +376,9 @@ def _compare_eq_cls(left, right, verbose, type_fns):
fields_to_check = [field for field, info in all_fields.items() if info.compare]
elif isattrs(left):
all_fields = left.__attrs_attrs__
fields_to_check = [field.name for field in all_fields if field.cmp]
fields_to_check = [
field.name for field in all_fields if getattr(field, ATTRS_EQ_FIELD)
]

same = []
diff = []
Expand Down
6 changes: 6 additions & 0 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,9 @@ def funcargnames(self):

def overload(f): # noqa: F811
return f


if getattr(attr, "__version_info__", ()) >= (19, 2):
ATTRS_EQ_FIELD = "eq"
else:
ATTRS_EQ_FIELD = "cmp"
4 changes: 3 additions & 1 deletion src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import attr

from ..compat import ascii_escaped
from ..compat import ATTRS_EQ_FIELD
from ..compat import getfslineno
from ..compat import NOTSET
from _pytest.outcomes import fail
Expand Down Expand Up @@ -367,7 +368,8 @@ def __repr__(self):
return "<NodeKeywords for node {}>".format(self.node)


@attr.s(cmp=False, hash=False)
# mypy cannot find this overload, remove when on attrs>=19.2
@attr.s(hash=False, **{ATTRS_EQ_FIELD: False}) # type: ignore
class NodeMarkers:
"""
internal structure for storing marks belonging to a node
Expand Down
17 changes: 8 additions & 9 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,14 @@ class RunResult:
Attributes:
:ret: the return value
:outlines: list of lines captured from stdout
:errlines: list of lines captures from stderr
:stdout: :py:class:`LineMatcher` of stdout, use ``stdout.str()`` to
:ivar ret: the return value
:ivar outlines: list of lines captured from stdout
:ivar errlines: list of lines captured from stderr
:ivar stdout: :py:class:`LineMatcher` of stdout, use ``stdout.str()`` to
reconstruct stdout or the commonly used ``stdout.fnmatch_lines()``
method
:stderr: :py:class:`LineMatcher` of stderr
:duration: duration in seconds
:ivar stderr: :py:class:`LineMatcher` of stderr
:ivar duration: duration in seconds
"""

def __init__(self, ret, outlines, errlines, duration):
Expand Down Expand Up @@ -454,9 +453,9 @@ class Testdir:
Attributes:
:tmpdir: The :py:class:`py.path.local` instance of the temporary directory.
:ivar tmpdir: The :py:class:`py.path.local` instance of the temporary directory.
:plugins: A list of plugins to use with :py:meth:`parseconfig` and
:ivar plugins: A list of plugins to use with :py:meth:`parseconfig` and
:py:meth:`runpytest`. Initially this is an empty list but plugins can
be added to the list. The type of items to add to the list depends on
the method using them so refer to them for details.
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def show_test_item(item):
tw = item.config.get_terminal_writer()
tw.line()
tw.write(" " * 8)
tw.write(item._nodeid)
used_fixtures = sorted(item._fixtureinfo.name2fixturedefs.keys())
tw.write(item.nodeid)
used_fixtures = sorted(getattr(item, "fixturenames", []))
if used_fixtures:
tw.write(" (fixtures used: {})".format(", ".join(used_fixtures)))

Expand Down
27 changes: 27 additions & 0 deletions testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,30 @@ def get_write_msg(self, idx):
fullwidth = 80

return TWMock()


@pytest.fixture
def dummy_yaml_custom_test(testdir):
"""Writes a conftest file that collects and executes a dummy yaml test.
Taken from the docs, but stripped down to the bare minimum, useful for
tests which needs custom items collected.
"""
testdir.makeconftest(
"""
import pytest
def pytest_collect_file(parent, path):
if path.ext == ".yaml" and path.basename.startswith("test"):
return YamlFile(path, parent)
class YamlFile(pytest.File):
def collect(self):
yield YamlItem(self.fspath.basename, self)
class YamlItem(pytest.Item):
def runtest(self):
pass
"""
)
testdir.makefile(".yaml", test1="")
6 changes: 3 additions & 3 deletions testing/python/setup_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def mode(request):
return request.param


def test_show_only_active_fixtures(testdir, mode):
p = testdir.makepyfile(
def test_show_only_active_fixtures(testdir, mode, dummy_yaml_custom_test):
testdir.makepyfile(
'''
import pytest
@pytest.fixture
Expand All @@ -21,7 +21,7 @@ def test_arg1(arg1):
'''
)

result = testdir.runpytest(mode, p)
result = testdir.runpytest(mode)
assert result.ret == 0

result.stdout.fnmatch_lines(
Expand Down

0 comments on commit b847d57

Please sign in to comment.