diff options
author | Nicolas Evrard <nicoe@openhex.org> | 2019-01-31 21:39:06 +0100 |
---|---|---|
committer | Paul Ganssle <paul@ganssle.io> | 2019-02-02 10:40:54 -0500 |
commit | a9f6d7410b0e22d063557e15f1ce291882d4745a (patch) | |
tree | 878cc5c64d72c9a1e1e3c4ca7bcdabea201791a5 | |
parent | 6618dee970ec1e5f92e0f48ec74584caf13075aa (diff) | |
download | dateutil-a9f6d7410b0e22d063557e15f1ce291882d4745a.tar.gz |
Short circuit evaluation of pytest get_marker
No version of pytest that works on Python 3.3 supports the
get_closest_marker method, and pytest >= 4.0 *only* supports
get_closest_marker, so we must retrieve item.get_marker *if and only if*
we cannot retrieve get_closest_marker.
-rw-r--r-- | changelog.d/857.misc.rst | 2 | ||||
-rw-r--r-- | dateutil/test/conftest.py | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/changelog.d/857.misc.rst b/changelog.d/857.misc.rst new file mode 100644 index 0000000..4ce9135 --- /dev/null +++ b/changelog.d/857.misc.rst @@ -0,0 +1,2 @@ +Fixed issue with get_marker API change introduced by pytest version >= 4.0 +Reported and fixed by @nicoe (gh issue #857, pr #858) diff --git a/dateutil/test/conftest.py b/dateutil/test/conftest.py index 3876b4d..78ed70a 100644 --- a/dateutil/test/conftest.py +++ b/dateutil/test/conftest.py @@ -6,9 +6,11 @@ import pytest # See: https://stackoverflow.com/a/53198349/467366 def pytest_collection_modifyitems(items): for item in items: + marker_getter = getattr(item, 'get_closest_marker', None) + # Python 3.3 support - marker_getter = getattr(item, 'get_closest_marker', - getattr(item, 'get_marker')) + if marker_getter is None: + marker_getter = item.get_marker marker = marker_getter('xfail') |