Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
59e6fb9
Fix "ValueError: Plugin already registered" exceptions when running i…
pstradomski Feb 7, 2019
391dc54
Add comment on why realpath is needed
pstradomski Feb 7, 2019
ddbea29
Remove terminal_reporter workaround from logging.py
twmr Feb 7, 2019
7bb504b
pytest.main: collect: factor out _visit_filter
blueyed Feb 8, 2019
b4b2f58
Merge pull request #4747 from blueyed/visit-filter
blueyed Feb 8, 2019
32c6d4f
Merge pull request #4738 from pstradomski/master
nicoddemus Feb 8, 2019
75a12b9
Ignore pip-generated 'pip-wheel-metadata' folder [skip ci]
nicoddemus Feb 8, 2019
76b0660
Merge pull request #4754 from nicoddemus/ignore-pip-wheel-metadata
nicoddemus Feb 8, 2019
7f6108b
Add ref docs for junit_family option
nicoddemus Feb 8, 2019
3a366f4
Merge pull request #4741 from thisch/refactor_terminalreporter
nicoddemus Feb 8, 2019
1950102
Merge pull request #4743 from nicoddemus/junit-ref
asottile Feb 9, 2019
fd1684e
tox: use deps for pluggymaster testenvs
blueyed Feb 10, 2019
f73fa47
Use coverage with pluggymaster
blueyed Feb 10, 2019
82b8ec3
Bump tox minversion
blueyed Feb 10, 2019
5e2d740
tox: cleanup/revisit deps
blueyed Feb 10, 2019
aee67bb
Clarify pytest_assertrepr_compare docs per #4759
kevinjfoley Feb 10, 2019
5cf05ce
Merge pull request #4764 from kevinjfoley/doc-assert-clarify
nicoddemus Feb 10, 2019
386e801
Merge pull request #4762 from blueyed/pluggymaster
RonnyPfannschmidt Feb 11, 2019
237f690
--lsof: suppress stderr
blueyed Feb 10, 2019
9feb494
pdb: fix capturing with recursive debugging and pdb++
blueyed Nov 8, 2018
61b9246
Fix/improve handling of pkg init and test file via args
blueyed Feb 8, 2019
dc8af18
Merge pull request #4745 from blueyed/test_collect_pkg_init_and_file_…
blueyed Feb 11, 2019
67dd10d
Merge pull request #4763 from blueyed/lsof
nicoddemus Feb 11, 2019
b4be228
Constrain more_itertools for Python 2.7 compatibility
Feb 12, 2019
a800328
Add CHANGELOG entry for #4770
Feb 12, 2019
f9c1329
Replace flatten() with chain.from_iterable
asottile Feb 12, 2019
8052d01
Merge pull request #4774 from sambrightman/pin-more_itertools
nicoddemus Feb 12, 2019
e20e376
Merge pull request #4347 from blueyed/pdb-recursive-capture
nicoddemus Feb 12, 2019
82cc3d8
Preparing release version 4.2.1
nicoddemus Feb 12, 2019
b595587
Set up CI with Azure Pipelines [skip travis] [skip appveyor]
nicoddemus Feb 12, 2019
215d537
Set junitxml and colors using PYTEST_ADDOPTS [skip travis] [skip appv…
nicoddemus Feb 12, 2019
04a941c
Pass PYTEST_ADDOPTS to tox envs [skip travis] [skip appveyor]
nicoddemus Feb 12, 2019
f729d5d
Remove --color=yes from PYTEST_ADDOPTS [skip travis] [skip appveyor]
nicoddemus Feb 12, 2019
f0e6bf7
Merge pull request #4775 from asottile/stdlib
asottile Feb 13, 2019
e26c5bd
Merge pull request #4776 from nicoddemus/release-4.2.1
nicoddemus Feb 13, 2019
8726be2
Merge pull request #4779 from pytest-dev/azure-pipelines
nicoddemus Feb 13, 2019
7b91952
Merge master into features
blueyed Feb 13, 2019
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ coverage.xml
.project
.settings
.vscode

# generated by pip
pip-wheel-metadata/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ env:
# Specialized factors for py27.
- TOXENV=py27-nobyte
- TOXENV=py27-xdist
- TOXENV=py27-pluggymaster PYTEST_NO_COVERAGE=1
- TOXENV=py27-pluggymaster
# Specialized factors for py37.
- TOXENV=py37-pexpect,py37-trial,py37-numpy
- TOXENV=py37-pluggymaster PYTEST_NO_COVERAGE=1
- TOXENV=py37-pluggymaster
- TOXENV=py37-freeze PYTEST_NO_COVERAGE=1

matrix:
Expand Down
56 changes: 56 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,62 @@ with advance notice in the **Deprecations** section of releases.

.. towncrier release notes start

pytest 4.2.1 (2019-02-12)
=========================

Bug Fixes
---------

- `#2895 <https://github.com/pytest-dev/pytest/issues/2895>`_: The ``pytest_report_collectionfinish`` hook now is also called with ``--collect-only``.


- `#3899 <https://github.com/pytest-dev/pytest/issues/3899>`_: Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module.


- `#4347 <https://github.com/pytest-dev/pytest/issues/4347>`_: Fix output capturing when using pdb++ with recursive debugging.


- `#4592 <https://github.com/pytest-dev/pytest/issues/4592>`_: Fix handling of ``collect_ignore`` via parent ``conftest.py``.


- `#4700 <https://github.com/pytest-dev/pytest/issues/4700>`_: Fix regression where ``setUpClass`` would always be called in subclasses even if all tests
were skipped by a ``unittest.skip()`` decorator applied in the subclass.


- `#4739 <https://github.com/pytest-dev/pytest/issues/4739>`_: Fix ``parametrize(... ids=<function>)`` when the function returns non-strings.


- `#4745 <https://github.com/pytest-dev/pytest/issues/4745>`_: Fix/improve collection of args when passing in ``__init__.py`` and a test file.


- `#4770 <https://github.com/pytest-dev/pytest/issues/4770>`_: ``more_itertools`` is now constrained to <6.0.0 when required for Python 2.7 compatibility.


- `#526 <https://github.com/pytest-dev/pytest/issues/526>`_: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.



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

- `#3899 <https://github.com/pytest-dev/pytest/issues/3899>`_: Add note to ``plugins.rst`` that ``pytest_plugins`` should not be used as a name for a user module containing plugins.


- `#4324 <https://github.com/pytest-dev/pytest/issues/4324>`_: Document how to use ``raises`` and ``does_not_raise`` to write parametrized tests with conditional raises.


- `#4709 <https://github.com/pytest-dev/pytest/issues/4709>`_: Document how to customize test failure messages when using
``pytest.warns``.



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

- `#4741 <https://github.com/pytest-dev/pytest/issues/4741>`_: Some verbosity related attributes of the TerminalReporter plugin are now
read only properties.


pytest 4.2.0 (2019-01-30)
=========================

Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ environment:
# Specialized factors for py27.
- TOXENV: "py27-trial,py27-numpy,py27-nobyte"
- TOXENV: "py27-pluggymaster"
PYTEST_NO_COVERAGE: "1"
# Specialized factors for py37.
- TOXENV: "py37-trial,py37-numpy"
- TOXENV: "py37-pluggymaster"
PYTEST_NO_COVERAGE: "1"
- TOXENV: "py37-freeze"
PYTEST_NO_COVERAGE: "1"

Expand Down
45 changes: 45 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
trigger:
- master
- features

variables:
PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml"

jobs:

- job: 'Test'
pool:
vmImage: "vs2017-win2016"
strategy:
matrix:
py27:
python.version: '2.7'
tox.env: 'py27'
py35:
python.version: '3.5'
tox.env: 'py35'
py36:
python.version: '3.6'
tox.env: 'py36'
py37:
python.version: '3.7'
tox.env: 'py37'
maxParallel: 4

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'

- script: python -m pip install --upgrade pip && pip install tox
displayName: 'Install tox'

- script: python -m tox -e $(tox.env)
displayName: 'Run tests'

- task: PublishTestResults@2
inputs:
testResultsFiles: 'build/test-results/$(tox.env).xml'
testRunTitle: '$(tox.env)'
condition: succeededOrFailed()
1 change: 0 additions & 1 deletion changelog/2895.bugfix.rst

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

2 changes: 0 additions & 2 deletions changelog/4700.bugfix.rst

This file was deleted.

2 changes: 0 additions & 2 deletions changelog/4709.doc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/4739.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-4.2.1
release-4.2.0
release-4.1.1
release-4.1.0
Expand Down
30 changes: 30 additions & 0 deletions doc/en/announce/release-4.2.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pytest-4.2.1
=======================================

pytest 4.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
* Arel Cordero
* Bruno Oliveira
* Daniel Hahler
* Holger Kohr
* Kevin J. Foley
* Nick Murphy
* Paweł Stradomski
* Raphael Pierzina
* Ronny Pfannschmidt
* Sam Brightman
* Thomas Hisch
* Zac Hatfield-Dodds


Happy testing,
The pytest Development Team
4 changes: 2 additions & 2 deletions doc/en/assert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ Special comparisons are done for a number of cases:

See the :ref:`reporting demo <tbreportdemo>` for many more examples.

Defining your own assertion comparison
----------------------------------------------
Defining your own explanation for failed assertions
---------------------------------------------------

It is possible to add your own detailed explanations by implementing
the ``pytest_assertrepr_compare`` hook.
Expand Down
14 changes: 14 additions & 0 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,20 @@ passed multiple times. The expected format is ``name=value``. For example::
This tells pytest to ignore deprecation warnings and turn all other warnings
into errors. For more information please refer to :ref:`warnings`.

.. confval:: junit_family

.. versionadded:: 4.2

Configures the format of the generated JUnit XML file. The possible options are:

* ``xunit1`` (or ``legacy``): produces old style output, compatible with the xunit 1.0 format. **This is the default**.
* ``xunit2``: produces `xunit 2.0 style output <https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__,
which should be more compatible with latest Jenkins versions.

.. code-block:: ini

[pytest]
junit_family = xunit2

.. confval:: junit_suite_name

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"six>=1.10.0",
"setuptools",
"attrs>=17.4.0",
"more-itertools>=4.0.0",
'more-itertools>=4.0.0,<6.0.0;python_version<="2.7"',
'more-itertools>=4.0.0;python_version>"2.7"',
"atomicwrites>=1.0",
'funcsigs;python_version<"3.0"',
'pathlib2>=2.2.0;python_version<"3.6"',
Expand Down
5 changes: 4 additions & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ def _getconftestmodules(self, path):
continue
conftestpath = parent.join("conftest.py")
if conftestpath.isfile():
mod = self._importconftest(conftestpath)
# Use realpath to avoid loading the same conftest twice
# with build systems that create build directories containing
# symlinks to actual files.
mod = self._importconftest(conftestpath.realpath())
clist.append(mod)
self._dirpath2confmods[directory] = clist
return clist
Expand Down
35 changes: 22 additions & 13 deletions src/_pytest/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class pytestPDB(object):
_config = None
_pdb_cls = pdb.Pdb
_saved = []
_recursive_debug = 0

@classmethod
def _init_pdb(cls, *args, **kwargs):
Expand All @@ -87,29 +88,37 @@ def _init_pdb(cls, *args, **kwargs):
capman.suspend_global_capture(in_=True)
tw = _pytest.config.create_terminal_writer(cls._config)
tw.line()
# Handle header similar to pdb.set_trace in py37+.
header = kwargs.pop("header", None)
if header is not None:
tw.sep(">", header)
elif capman and capman.is_globally_capturing():
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
else:
tw.sep(">", "PDB set_trace")
if cls._recursive_debug == 0:
# Handle header similar to pdb.set_trace in py37+.
header = kwargs.pop("header", None)
if header is not None:
tw.sep(">", header)
elif capman and capman.is_globally_capturing():
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
else:
tw.sep(">", "PDB set_trace")

class _PdbWrapper(cls._pdb_cls, object):
_pytest_capman = capman
_continued = False

def do_debug(self, arg):
cls._recursive_debug += 1
ret = super(_PdbWrapper, self).do_debug(arg)
cls._recursive_debug -= 1
return ret

def do_continue(self, arg):
ret = super(_PdbWrapper, self).do_continue(arg)
if self._pytest_capman:
tw = _pytest.config.create_terminal_writer(cls._config)
tw.line()
if self._pytest_capman.is_globally_capturing():
tw.sep(">", "PDB continue (IO-capturing resumed)")
else:
tw.sep(">", "PDB continue")
self._pytest_capman.resume_global_capture()
if cls._recursive_debug == 0:
if self._pytest_capman.is_globally_capturing():
tw.sep(">", "PDB continue (IO-capturing resumed)")
else:
tw.sep(">", "PDB continue")
self._pytest_capman.resume_global_capture()
cls._pluginmanager.hook.pytest_leave_pdb(
config=cls._config, pdb=self
)
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import functools
import inspect
import itertools
import sys
import warnings
from collections import defaultdict
Expand All @@ -13,7 +14,6 @@
import attr
import py
import six
from more_itertools import flatten

import _pytest
from _pytest import nodes
Expand Down Expand Up @@ -1109,7 +1109,7 @@ def getfixtureinfo(self, node, func, cls, funcargs=True):
argnames = getfuncargnames(func, cls=cls)
else:
argnames = ()
usefixtures = flatten(
usefixtures = itertools.chain.from_iterable(
mark.args for mark in node.iter_markers(name="usefixtures")
)
initialnames = tuple(usefixtures) + argnames
Expand Down
7 changes: 0 additions & 7 deletions src/_pytest/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,6 @@ def _setup_cli_logging(self):
# terminal reporter is disabled e.g. by pytest-xdist.
return

# FIXME don't set verbosity level and derived attributes of
# terminalwriter directly
terminal_reporter.verbosity = config.option.verbose
terminal_reporter.showheader = terminal_reporter.verbosity >= 0
terminal_reporter.showfspath = terminal_reporter.verbosity >= 0
terminal_reporter.showlongtestinfo = terminal_reporter.verbosity > 0

capture_manager = config.pluginmanager.get_plugin("capturemanager")
# if capturemanager plugin is disabled, live logging still works.
log_cli_handler = _LiveLoggingStreamHandler(terminal_reporter, capture_manager)
Expand Down
26 changes: 14 additions & 12 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,9 @@ def _collect(self, arg):
if argpath.check(dir=1):
assert not names, "invalid arg %r" % (arg,)

if six.PY2:

def filter_(f):
return f.check(file=1) and not f.strpath.endswith("*.pyc")

else:

def filter_(f):
return f.check(file=1)

seen_dirs = set()
for path in argpath.visit(
fil=filter_, rec=self._recurse, bf=True, sort=True
fil=self._visit_filter, rec=self._recurse, bf=True, sort=True
):
dirpath = path.dirpath()
if dirpath not in seen_dirs:
Expand Down Expand Up @@ -613,7 +603,7 @@ def filter_(f):
col = self._node_cache[argpath]
else:
collect_root = self._pkg_roots.get(argpath.dirname, self)
col = collect_root._collectfile(argpath)
col = collect_root._collectfile(argpath, handle_dupes=False)
if col:
self._node_cache[argpath] = col
m = self.matchnodes(col, names)
Expand Down Expand Up @@ -658,6 +648,18 @@ def _recurse(self, dirpath):
ihook.pytest_collect_directory(path=dirpath, parent=self)
return True

if six.PY2:

@staticmethod
def _visit_filter(f):
return f.check(file=1) and not f.strpath.endswith("*.pyc")

else:

@staticmethod
def _visit_filter(f):
return f.check(file=1)

def _tryconvertpyarg(self, x):
"""Convert a dotted module name to path."""
try:
Expand Down
Loading