diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 82df8f7e0..705d43121 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -34,7 +34,7 @@ jobs: python -m pip install -r requirements.txt python -m pip install -r docs/requirements.txt python -m pip install -r requirements-tests.txt - python setup.py develop + python -m pip install -e . - name: Run Tests run: | diff --git a/Makefile b/Makefile index 8af460284..e259ed417 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,10 @@ help: @echo " deploy_docs to deploy the docs to Github Pages" install: - python3 setup.py develop + python3 -m pip install -e . test: - python3 tests.py + pytest docs: cd $(DOCS_DIR) ; make html diff --git a/requirements-tests.txt b/requirements-tests.txt index 26b2829b1..0a57b82e9 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,7 @@ pytest==7.1.2 pytest-mock coverage coveralls -bokeh +bokeh>=3.0.0 nbval pytest-cov pygments diff --git a/setup.py b/setup.py index 9609d7238..139c5dd67 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ import sys from setuptools import setup -from setuptools.command.test import test as TestCommand if sys.version_info < (3, 6): @@ -9,38 +8,15 @@ with open('requirements.txt') as fid: install_requires = [l.strip() for l in fid.readlines() if l] -tests_requires = [ - 'pytest', - 'coverage', - 'coveralls', - 'bokeh' -] - with open('datascience/version.py') as fid: for line in fid: if line.startswith('__version__'): version = line.strip().split()[-1][1:-1] break -class PyTest(TestCommand): - user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = ['--nbval-lax', '--cov=datascience', 'tests'] - - def finalize_options(self): - TestCommand.finalize_options(self) - - def pytest_collectstart(collector): - collector.skip_compare += 'text/html' - - def run_tests(self): - # import here, cause outside the eggs aren't loaded - import pytest - errno = pytest.main(self.pytest_args) - sys.exit(errno) - +# Test dependencies are listed in requirements-tests.txt and the test suite is +# run with pytest directly (`make test`). The `setup.py test` command was +# removed in Setuptools 72, so it is no longer wired up here. setup( name = 'datascience', @@ -48,8 +24,6 @@ def run_tests(self): python_requires='>=3.6', version = version, install_requires = install_requires, - tests_require = tests_requires, - cmdclass = {'test': PyTest}, description = 'A Jupyter notebook Python library for introductory data science', long_description = 'A Jupyter notebook Python library for introductory data science', author = 'John DeNero, David Culler, Alvin Wan, Sam Lau', diff --git a/tests.py b/tests.py index 1b4a53d48..3f512248b 100644 --- a/tests.py +++ b/tests.py @@ -1,5 +1,13 @@ -import pytest +"""Convenience entry point for running the test suite. + +Prefer invoking ``pytest`` directly (or ``make test``). The pytest options for +this project live in the ``[pytest]`` section of ``tox.ini``, so no arguments +need to be passed here. +""" + import sys +import pytest + if __name__ == "__main__": - sys.exit(pytest.main(['--nbval-lax', '--cov=datascience', 'tests'])) \ No newline at end of file + sys.exit(pytest.main(sys.argv[1:])) diff --git a/tox.ini b/tox.ini index bc143fca3..b733d5ec0 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,13 @@ deps = snowballstemmer sphinx sphinx-rtd-theme + bokeh>=3.0.0 + bokeh_sampledata commands = - python setup.py test + pytest + +[pytest] +addopts = --nbval-lax --cov=datascience +testpaths = tests