From 413c74c27c4c0944dcca6d9a11c5935d32451546 Mon Sep 17 00:00:00 2001 From: Unrud Date: Sat, 2 Jul 2022 20:37:52 +0200 Subject: [PATCH] Remove pytest-runner --- .github/workflows/test.yml | 2 +- conftest.py | 9 +++++++++ setup.cfg | 8 +++----- setup.py | 18 ++++-------------- 4 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 conftest.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aef9560..88ebec2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - name: Install from source run: python -m pip install --editable .[test,bcrypt] - name: Run tests - run: python setup.py test + run: python -m pytest - name: Upload coverage to Coveralls if: github.event_name == 'push' env: diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..1775397 --- /dev/null +++ b/conftest.py @@ -0,0 +1,9 @@ +import sys +from importlib.util import find_spec + + +def pytest_addoption(parser, pluginmanager): + # Ignore the "--mypy" argument if pytest-mypy is not installed and + # the implementation is not cpython + if sys.implementation.name != 'cpython' and not find_spec("pytest_mypy"): + parser.addoption("--mypy", action="store_true") diff --git a/setup.cfg b/setup.cfg index 35c2c8e..06753b4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,10 @@ -[aliases] -test = pytest - [bdist_wheel] python-tag = py3 [tool:pytest] -# More options are set in `setup.py` via environment variable `PYTEST_ADDOPTS` -addopts = --flake8 --isort --typeguard-packages=radicale --cov --cov-report=term --cov-report=xml -r s +# The "--mypy" argument is ignored in conftest.py if pytest-mypy is not +# installed and the implementation is not cpython +addopts = --flake8 --isort --typeguard-packages=radicale --mypy --cov --cov-report=term --cov-report=xml -r s norecursedirs = dist .cache .git build Radicale.egg-info .eggs venv [tool:isort] diff --git a/setup.py b/setup.py index c9c4bba..3aa336f 100644 --- a/setup.py +++ b/setup.py @@ -36,9 +36,6 @@ For further information, please visit the `Radicale Website """ -import os -import sys - from setuptools import find_packages, setup # When the version is updated, a new section in the CHANGELOG.md file must be @@ -52,16 +49,10 @@ WEB_FILES = ["web/internal_data/css/icon.png", install_requires = ["defusedxml", "passlib", "vobject>=0.9.6", "python-dateutil>=2.7.3", "setuptools; python_version<'3.9'"] -setup_requires = [] -if {"pytest", "test", "ptr"}.intersection(sys.argv): - setup_requires.append("pytest-runner") -tests_require = ["pytest-runner", "pytest<7", "pytest-cov", "pytest-flake8", - "pytest-isort", "typeguard", "waitress"] -os.environ["PYTEST_ADDOPTS"] = os.environ.get("PYTEST_ADDOPTS", "") -# Mypy only supports CPython -if sys.implementation.name == "cpython": - tests_require.extend(["pytest-mypy", "types-setuptools"]) - os.environ["PYTEST_ADDOPTS"] += " --mypy" +tests_require = ["pytest", "pytest-cov", "pytest-flake8", "pytest-isort", + "typeguard", "waitress", + "pytest-mypy; implementation_name=='cpython'", + "types-setuptools; implementation_name=='cpython'"] setup( name="Radicale", @@ -80,7 +71,6 @@ setup( package_data={"radicale": [*WEB_FILES, "py.typed"]}, entry_points={"console_scripts": ["radicale = radicale.__main__:run"]}, install_requires=install_requires, - setup_requires=setup_requires, tests_require=tests_require, extras_require={"test": tests_require, "bcrypt": ["passlib[bcrypt]", "bcrypt"]},