Skip to content

Merge master into features #3387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ff3d13e
Update typo in fixture.rst
nicoddemus Mar 26, 2018
34afded
Update pytest.raises to raise a TypeError when an invalid keyword arg…
jeffreyrack Mar 28, 2018
a5d9fbe
Change pytest.raises to use match instead of matches
jeffreyrack Mar 28, 2018
bfe773b
Use shorter 'if kwargs' check as requested during review
nicoddemus Mar 28, 2018
7656581
Update changelog formatting
nicoddemus Mar 28, 2018
2efaf39
Merge pull request #3349 from jeffreyrack/3348-unknown-argument
RonnyPfannschmidt Mar 28, 2018
0a3cd88
Add docs about using pytest.param in parametrized fixtures
nicoddemus Mar 28, 2018
f1c9efc
Merge pull request #3353 from nicoddemus/fixture-param-marks-docs
RonnyPfannschmidt Mar 29, 2018
faded25
chage collections.abc import to fix deprecation warnings on python 3.7
irmen Mar 29, 2018
8ca9321
Move compatibility imports to compat.py and fix linting
nicoddemus Mar 29, 2018
6a81aae
Move compatibility imports to compat.py and fix linting
nicoddemus Mar 29, 2018
e5eba84
Remove stale CHANGELOG entries
nicoddemus Mar 29, 2018
daf1de0
Add reference docs for pytest_sessionstart/finish and update their do…
nicoddemus Mar 29, 2018
3fc2c94
Switch imports based on python versions, my bad
nicoddemus Mar 30, 2018
77128ee
Merge pull request #3356 from nicoddemus/remove-stale-changelog-entries
flub Mar 30, 2018
211f3c4
record_property is no longer experimental
RonnyPfannschmidt Apr 1, 2018
9a62ebf
Merge pull request #3355 from irmen/py37deprfixes
nicoddemus Apr 2, 2018
9326759
Merge pull request #3357 from nicoddemus/session-hooks-ref
RonnyPfannschmidt Apr 3, 2018
7c0c91a
fix record_property test
RonnyPfannschmidt Apr 3, 2018
9aa2a83
Use correct spelling for "more-itertools"
Apr 3, 2018
ad0b433
Merge pull request #3364 from sscherfke/more-itertools
RonnyPfannschmidt Apr 3, 2018
2018cf1
fix the record_property test
RonnyPfannschmidt Apr 5, 2018
db24723
no-capture in sample code demo'ing plugin
dchudz Apr 5, 2018
ef34de9
Merge pull request #3360 from RonnyPfannschmidt/xml_property_yay
nicoddemus Apr 5, 2018
ab91771
Merge pull request #3370 from dchudz/patch-1
nicoddemus Apr 5, 2018
f17dfa4
Remove label descriptions from development guide
nicoddemus Apr 5, 2018
5d4fe87
Merge pull request #3371 from nicoddemus/remove-labels-descriptions
RonnyPfannschmidt Apr 6, 2018
ec2d822
Fix issue #3372
Ohj8odah Apr 6, 2018
0cd74dc
Ensure object is class before calling issubclass.
Ohj8odah Apr 6, 2018
846d91f
Follow Ronny's advice and use ``type`` in ``base_type``.
Ohj8odah Apr 6, 2018
5bd8561
linting: unfortunate dedent be gone.
Ohj8odah Apr 6, 2018
e012dbe
Merge pull request #3373 from backbord/master
nicoddemus Apr 7, 2018
10a7160
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Apr 11, 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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Tareq Alayan
Ted Xiao
Thomas Grainger
Thomas Hisch
Tim Strazny
Tom Dalton
Tom Viner
Trevor Bekolay
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Trivial/Internal Changes
- Internal ``mark.py`` module has been turned into a package. (`#3250
<https://github.com/pytest-dev/pytest/issues/3250>`_)

- ``pytest`` now depends on the `more_itertools
- ``pytest`` now depends on the `more-itertools
<https://github.com/erikrose/more-itertools>`_ package. (`#3265
<https://github.com/pytest-dev/pytest/issues/3265>`_)

Expand Down
2 changes: 1 addition & 1 deletion _pytest/assertion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import _pytest._code
import py
import six
from collections import Sequence
from ..compat import Sequence

u = six.text_type

Expand Down
8 changes: 8 additions & 0 deletions _pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
PY36 = sys.version_info[:2] >= (3, 6)
MODULE_NOT_FOUND_ERROR = 'ModuleNotFoundError' if PY36 else 'ImportError'

if _PY3:
from collections.abc import MutableMapping as MappingMixin # noqa
from collections.abc import Sequence # noqa
else:
# those raise DeprecationWarnings in Python >=3.7
from collections import MutableMapping as MappingMixin # noqa
from collections import Sequence # noqa


def _format_args(func):
return str(signature(func))
Expand Down
5 changes: 3 additions & 2 deletions _pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,15 @@ def pytest_fixture_post_finalizer(fixturedef, request):


def pytest_sessionstart(session):
""" before session.main() is called.
""" called after the ``Session`` object has been created and before performing collection
and entering the run test loop.
:param _pytest.main.Session session: the pytest session object
"""


def pytest_sessionfinish(session, exitstatus):
""" whole test run finishes.
""" called after whole test run finished, right before returning the exit status to the system.
:param _pytest.main.Session session: the pytest session object
:param int exitstatus: the status which pytest will return to the system
Expand Down
5 changes: 0 additions & 5 deletions _pytest/junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ def record_property(request):
def test_function(record_property):
record_property("example_key", 1)
"""
request.node.warn(
code='C3',
message='record_property is an experimental feature',
)

def append_property(name, value):
request.node.user_properties.append((name, value))
return append_property
Expand Down
3 changes: 2 additions & 1 deletion _pytest/mark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class MarkerError(Exception):


def param(*values, **kw):
"""Specify a parameter in a `pytest.mark.parametrize`_ call.
"""Specify a parameter in `pytest.mark.parametrize`_ calls or
:ref:`parametrized fixtures <fixture-parametrize-marks>`.

.. code-block:: python

Expand Down
6 changes: 3 additions & 3 deletions _pytest/mark/structures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from collections import namedtuple, MutableMapping as MappingMixin
import inspect
import warnings
from collections import namedtuple
from operator import attrgetter
import inspect

import attr

from ..deprecated import MARK_PARAMETERSET_UNPACKING, MARK_INFO_ATTRIBUTE
from ..compat import NOTSET, getfslineno
from ..compat import NOTSET, getfslineno, MappingMixin
from six.moves import map, reduce


Expand Down
8 changes: 7 additions & 1 deletion _pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys

import py
from six import binary_type, text_type
from six.moves import zip, filterfalse
from more_itertools.more import always_iterable

Expand Down Expand Up @@ -584,7 +585,8 @@ def raises(expected_exception, *args, **kwargs):

"""
__tracebackhide__ = True
for exc in filterfalse(isclass, always_iterable(expected_exception)):
base_type = (type, text_type, binary_type)
for exc in filterfalse(isclass, always_iterable(expected_exception, base_type)):
msg = ("exceptions must be old-style classes or"
" derived from BaseException, not %s")
raise TypeError(msg % type(exc))
Expand All @@ -597,6 +599,10 @@ def raises(expected_exception, *args, **kwargs):
message = kwargs.pop("message")
if "match" in kwargs:
match_expr = kwargs.pop("match")
if kwargs:
msg = 'Unexpected keyword arguments passed to pytest.raises: '
msg += ', '.join(kwargs.keys())
raise TypeError(msg)
return RaisesContext(expected_exception, message, match_expr)
elif isinstance(args[0], str):
code, = args
Expand Down
1 change: 0 additions & 1 deletion changelog/1478.feature

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

2 changes: 0 additions & 2 deletions changelog/2770.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/2770.removal.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3034.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3084.removal

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3139.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3149.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3156.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3189.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3190.feature

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3204.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3213.feature

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3246.trival.rst

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3268.trivial

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3296.feature

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3296.trivial

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3304.trivial

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3312.feature

This file was deleted.

3 changes: 0 additions & 3 deletions changelog/3314.bugfix.rst

This file was deleted.

1 change: 1 addition & 0 deletions changelog/3339.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Import some modules from ``collections`` instead of ``collections.abc`` as the former modules trigger ``DeprecationWarning`` in Python 3.7.
1 change: 1 addition & 0 deletions changelog/3348.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pytest.raises`` now raises ``TypeError`` when receiving an unknown keyword argument.
2 changes: 2 additions & 0 deletions changelog/3360.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
record_property is no longer experimental, removing the warnings was forgotten.

1 change: 1 addition & 0 deletions changelog/3372.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pytest.raises`` now works with exception classes that look like iterables.
71 changes: 9 additions & 62 deletions doc/en/development_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Development Guide
=================

Some general guidelines regarding development in pytest for core maintainers and general contributors. Nothing here
Some general guidelines regarding development in pytest for maintainers and contributors. Nothing here
is set in stone and can't be changed, feel free to suggest improvements or changes in the workflow.


Expand Down Expand Up @@ -37,72 +37,19 @@ Any question, feature, bug or proposal is welcome as an issue. Users are encoura
GitHub issues should use labels to categorize them. Labels should be created sporadically, to fill a niche; we should
avoid creating labels just for the sake of creating them.

Here is a list of labels and a brief description mentioning their intent.
Each label should include a description in the GitHub's interface stating its purpose.

Temporary labels
~~~~~~~~~~~~~~~~

**Type**
To classify issues for a special event it is encouraged to create a temporary label. This helps those involved to find
the relevant issues to work on. Examples of that are sprints in Python events or global hacking events.

* ``type: backward compatibility``: issue that will cause problems with old pytest versions.
* ``type: bug``: problem that needs to be addressed.
* ``type: deprecation``: feature that will be deprecated in the future.
* ``type: docs``: documentation missing or needing clarification.
* ``type: enhancement``: new feature or API change, should be merged into ``features``.
* ``type: feature-branch``: new feature or API change, should be merged into ``features``.
* ``type: infrastructure``: improvement to development/releases/CI structure.
* ``type: performance``: performance or memory problem/improvement.
* ``type: proposal``: proposal for a new feature, often to gather opinions or design the API around the new feature.
* ``type: question``: question regarding usage, installation, internals or how to test something.
* ``type: refactoring``: internal improvements to the code.
* ``type: regression``: indicates a problem that was introduced in a release which was working previously.
* ``temporary: EP2017 sprint``: candidate issues or PRs tackled during the EuroPython 2017

**Status**
Issues created at those events should have other relevant labels added as well.

* ``status: critical``: grave problem or usability issue that affects lots of users.
* ``status: easy``: easy issue that is friendly to new contributors.
* ``status: help wanted``: core developers need help from experts on this topic.
* ``status: needs information``: reporter needs to provide more information; can be closed after 2 or more weeks of inactivity.

**Topic**

* ``topic: collection``
* ``topic: fixtures``
* ``topic: parametrize``
* ``topic: reporting``
* ``topic: selection``
* ``topic: tracebacks``

**Plugin (internal or external)**

* ``plugin: cache``
* ``plugin: capture``
* ``plugin: doctests``
* ``plugin: junitxml``
* ``plugin: monkeypatch``
* ``plugin: nose``
* ``plugin: pastebin``
* ``plugin: pytester``
* ``plugin: tmpdir``
* ``plugin: unittest``
* ``plugin: warnings``
* ``plugin: xdist``


**OS**

Issues specific to a single operating system. Do not use as a means to indicate where an issue originated from, only
for problems that happen **only** in that system.

* ``os: linux``
* ``os: mac``
* ``os: windows``

**Temporary**

Used to classify issues for limited time, to help find issues related in events for example.
They should be removed after they are no longer relevant.

* ``temporary: EP2017 sprint``:
* ``temporary: sprint-candidate``:
Those labels should be removed after they are no longer relevant.


.. include:: ../../HOWTORELEASE.rst
2 changes: 1 addition & 1 deletion doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ get on the terminal - we are working on that)::
> int(s)
E ValueError: invalid literal for int() with base 10: 'qwe'

<0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python_api.py:609>:1: ValueError
<0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python_api.py:613>:1: ValueError
______________________ TestRaises.test_raises_doesnt _______________________

self = <failure_demo.TestRaises object at 0xdeadbeef>
Expand Down
36 changes: 35 additions & 1 deletion doc/en/fixture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ The fixtures requested by ``test_foo`` will be instantiated in the following ord

1. ``s1``: is the highest-scoped fixture (``session``).
2. ``m1``: is the second highest-scoped fixture (``module``).
3. ``tempdir``: is a ``function``-scoped fixture, required by ``f1``: it needs to be instantiated at this point
3. ``tmpdir``: is a ``function``-scoped fixture, required by ``f1``: it needs to be instantiated at this point
because it is a dependency of ``f1``.
4. ``f1``: is the first ``function``-scoped fixture in ``test_foo`` parameter list.
5. ``f2``: is the last ``function``-scoped fixture in ``test_foo`` parameter list.
Expand Down Expand Up @@ -623,6 +623,40 @@ Running the above tests results in the following test IDs being used::

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

.. _`fixture-parametrize-marks`:

Using marks with parametrized fixtures
--------------------------------------

:func:`pytest.param` can be used to apply marks in values sets of parametrized fixtures in the same way
that they can be used with :ref:`@pytest.mark.parametrize <@pytest.mark.parametrize>`.

Example::

# content of test_fixture_marks.py
import pytest
@pytest.fixture(params=[0, 1, pytest.param(2, marks=pytest.mark.skip)])
def data_set(request):
return request.param

def test_data(data_set):
pass

Running this test will *skip* the invocation of ``data_set`` with value ``2``::

$ pytest test_fixture_marks.py -v
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.5
cachedir: .pytest_cache
rootdir: $REGENDOC_TMPDIR, inifile:
collecting ... collected 3 items

test_fixture_marks.py::test_data[0] PASSED [ 33%]
test_fixture_marks.py::test_data[1] PASSED [ 66%]
test_fixture_marks.py::test_data[2] SKIPPED [100%]

=================== 2 passed, 1 skipped in 0.12 seconds ====================

.. _`interdependent fixtures`:

Modularity: using fixtures from a fixture function
Expand Down
2 changes: 2 additions & 0 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ Initialization hooks called for plugins and ``conftest.py`` files.
.. autofunction:: pytest_addhooks
.. autofunction:: pytest_configure
.. autofunction:: pytest_unconfigure
.. autofunction:: pytest_sessionstart
.. autofunction:: pytest_sessionfinish

Test running hooks
~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions doc/en/writing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ sub directory but not for other directories::

Here is how you might run it::

pytest test_flat.py # will not show "setting up"
pytest a/test_sub.py # will show "setting up"
    pytest test_flat.py --capture=no # will not show "setting up"
pytest a/test_sub.py --capture=no # will show "setting up"

.. note::
If you have ``conftest.py`` files which do not reside in a
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main():
'six>=1.10.0',
'setuptools',
'attrs>=17.4.0',
'more_itertools>=4.0.0',
'more-itertools>=4.0.0',
]
# if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy;
# used by tox.ini to test with pluggy master
Expand Down
Loading