]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix conftest.py compatibility with pytest 4.3
authorMiro Hrončok <miro@hroncok.cz>
Thu, 14 Mar 2019 18:54:42 +0000 (19:54 +0100)
committerMiro Hrončok <miro@hroncok.cz>
Thu, 14 Mar 2019 18:54:42 +0000 (19:54 +0100)
While pytest in tox.ini is explicitly set to be 3.3.2, in Fedora 31
we are about to update to a newer version of pytest.
In order to be able to test babel, we need pytest 4.3 support.

This adds support for pytest 4.3 without breaking support for 3.3.2.

tests/conftest.py

index be93b2be7a90cd419e41f97e9ca9f9b7faf90b83..5b14b1ca72350e2d83614befe3df8920ffd520e7 100644 (file)
@@ -10,6 +10,9 @@ def os_environ(monkeypatch):
 
 
 def pytest_generate_tests(metafunc):
-    if hasattr(metafunc.function, "all_locales"):
-        from babel.localedata import locale_identifiers
-        metafunc.parametrize("locale", list(locale_identifiers()))
+    if hasattr(metafunc.function, "pytestmark"):
+        for mark in metafunc.function.pytestmark:
+            if mark.name == "all_locales":
+                from babel.localedata import locale_identifiers
+                metafunc.parametrize("locale", list(locale_identifiers()))
+                break