summaryrefslogtreecommitdiff
path: root/_pytest
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2018-04-12 08:39:22 +0200
committerGitHub <noreply@github.com>2018-04-12 08:39:22 +0200
commitf79b0324fe21eb35918ca67421f9967fa23c0e3b (patch)
treed7568cc6bdf500f92bc15e02fa167dcbb21a7b55 /_pytest
parent372bcdba0c9a9f84ad9aaec121e0d945a7785013 (diff)
parent10a71605498d50851e937837fafe2d2672ea2bd4 (diff)
downloadpytest-f79b0324fe21eb35918ca67421f9967fa23c0e3b.tar.gz
Merge pull request #3387 from nicoddemus/merge-master-into-features
Merge master into features
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/assertion/util.py2
-rw-r--r--_pytest/compat.py8
-rw-r--r--_pytest/hookspec.py5
-rw-r--r--_pytest/junitxml.py5
-rw-r--r--_pytest/mark/__init__.py3
-rw-r--r--_pytest/mark/structures.py6
-rw-r--r--_pytest/python_api.py8
7 files changed, 24 insertions, 13 deletions
diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py
index 5a380ae09..06d60a6fc 100644
--- a/_pytest/assertion/util.py
+++ b/_pytest/assertion/util.py
@@ -5,7 +5,7 @@ import pprint
import _pytest._code
import py
import six
-from collections import Sequence
+from ..compat import Sequence
u = six.text_type
diff --git a/_pytest/compat.py b/_pytest/compat.py
index 92df65656..bcb31cb88 100644
--- a/_pytest/compat.py
+++ b/_pytest/compat.py
@@ -38,6 +38,14 @@ PY35 = sys.version_info[:2] >= (3, 5)
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))
diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py
index 70349416e..f5bdfabc5 100644
--- a/_pytest/hookspec.py
+++ b/_pytest/hookspec.py
@@ -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
diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py
index 5207c2514..3a0e4a071 100644
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -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
diff --git a/_pytest/mark/__init__.py b/_pytest/mark/__init__.py
index 51540dbd7..7c96116d1 100644
--- a/_pytest/mark/__init__.py
+++ b/_pytest/mark/__init__.py
@@ -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
diff --git a/_pytest/mark/structures.py b/_pytest/mark/structures.py
index 451614d92..5b33f3abb 100644
--- a/_pytest/mark/structures.py
+++ b/_pytest/mark/structures.py
@@ -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
diff --git a/_pytest/python_api.py b/_pytest/python_api.py
index 69ae6ed0e..8e09a4a6f 100644
--- a/_pytest/python_api.py
+++ b/_pytest/python_api.py
@@ -2,6 +2,7 @@ import math
import sys
import py
+from six import binary_type, text_type
from six.moves import zip, filterfalse
from more_itertools.more import always_iterable
@@ -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))
@@ -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