diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-05-22 20:57:29 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-22 20:57:29 -0300 |
commit | 7985eff5b4b824576c0a1a98ddf31cbce14498ef (patch) | |
tree | 85d33c4f6346a63ded4d057ece85ed00694b8a20 | |
parent | 6c8d46d8ea2341ef20362d8f46665f7e563b9821 (diff) | |
parent | 5072226f69ce7bb2fedd091d3e84cb40fac390ec (diff) | |
download | pytest-7985eff5b4b824576c0a1a98ddf31cbce14498ef.tar.gz |
Merge pull request #3497 from hroncok/approx_compat_import
Import Mapping and Sequence from compat in python_api::approx
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | _pytest/compat.py | 4 | ||||
-rw-r--r-- | _pytest/python_api.py | 2 | ||||
-rw-r--r-- | changelog/3497.trivial.rst | 5 |
4 files changed, 9 insertions, 3 deletions
@@ -144,6 +144,7 @@ Michael Seifert Michal Wajszczuk Mihai Capotă Mike Lundy +Miro Hrončok Nathaniel Waisbrot Ned Batchelder Neven Mundar diff --git a/_pytest/compat.py b/_pytest/compat.py index e5c8c3940..abad4f3c5 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -40,11 +40,11 @@ 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 + from collections.abc import Mapping, Sequence # noqa else: # those raise DeprecationWarnings in Python >=3.7 from collections import MutableMapping as MappingMixin # noqa - from collections import Sequence # noqa + from collections import Mapping, Sequence # noqa def _format_args(func): diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 8e09a4a6f..838a4a50c 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -426,7 +426,7 @@ def approx(expected, rel=None, abs=None, nan_ok=False): __ https://docs.python.org/3/reference/datamodel.html#object.__ge__ """ - from collections import Mapping, Sequence + from _pytest.compat import Mapping, Sequence from _pytest.compat import STRING_TYPES as String from decimal import Decimal diff --git a/changelog/3497.trivial.rst b/changelog/3497.trivial.rst new file mode 100644 index 000000000..c7aca0ec3 --- /dev/null +++ b/changelog/3497.trivial.rst @@ -0,0 +1,5 @@ +Import ``Mapping`` and ``Sequence`` from ``_pytest.compat`` instead of directly +from ``collections`` in ``python_api.py::approx``. Add ``Mapping`` to +``_pytest.compat``, import it from ``collections`` on python 2, but from +``collections.abc`` on Python 3 to avoid a ``DeprecationWarning`` on +Python 3.7 or newer. |