From e0d81113e61b26fc18a1d34225def394c5337c59 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Fri, 4 Feb 2022 13:20:36 -0800 Subject: [PATCH] dev: Avoid pytest 7.0.0 on Python 3.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It contains a fatal bug¹ when used on 3.9 because it incorrectly guards a 3.10-only implementation detail with a >=3.9 version check, which results in: ModuleNotFoundError: No module named 'importlib.readers' when trying to load/parse Python modules. Pytest 7.0.0 is only ~11 hours old at the moment, and another person filed the upstream bug report as I was writing my own. What a life, living on the edge. 😬 Adjusts the warnings filter slightly in pytest.ini because PytestRemovedIn8Warning is only present in pytest 7 and for now our tests on 3.9 will use pytest 6. ¹ https://github.com/pytest-dev/pytest/issues/9608 --- pytest.ini | 2 +- setup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index da67dd11..1ea7f807 100644 --- a/pytest.ini +++ b/pytest.ini @@ -14,4 +14,4 @@ filterwarnings = error ignore:SelectableGroups dict interface:DeprecationWarning:flake8 ignore: is not using a cooperative constructor:pytest.PytestDeprecationWarning - ignore:The .+? argument to Flake8Item is deprecated:pytest.PytestRemovedIn8Warning + ignore:The .+? argument to Flake8Item is deprecated:pytest.PytestDeprecationWarning diff --git a/setup.py b/setup.py index 07488abe..c8152c82 100644 --- a/setup.py +++ b/setup.py @@ -122,7 +122,8 @@ def find_namespaced_packages(namespace): "flake8", "mypy", "nextstrain-sphinx-theme", - "pytest", + "pytest; python_version != '3.9'", + "pytest !=7.0.0; python_version == '3.9'", "pytest-flake8", "recommonmark", "sphinx>=3",