From 49d57729e8b22147b23047e24900371e610c190e Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Tue, 24 Aug 2021 21:21:05 +0100 Subject: [PATCH] pytest: package conftest (#576) closes #563 * Package the conftest file. * This changes the test command to `pytest jupyter_server`. * Import the `jupyter_server.conftest` in the examples to inherit the plugin. --- .github/workflows/integration-tests.yml | 2 +- .github/workflows/python-linux.yml | 6 +++--- .github/workflows/python-macos.yml | 6 +++--- .github/workflows/python-windows.yml | 4 ++-- CONTRIBUTING.rst | 6 +++--- examples/simple/conftest.py | 1 + conftest.py => jupyter_server/conftest.py | 0 pyproject.toml | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 examples/simple/conftest.py rename conftest.py => jupyter_server/conftest.py (100%) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d800700983..9ac6778533 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -44,4 +44,4 @@ jobs: pip check - name: Run the tests run: | - pytest -vv --integration_tests=true + pytest -vv --integration_tests=true jupyter_server diff --git a/.github/workflows/python-linux.yml b/.github/workflows/python-linux.yml index 7e6ae01c07..2a6404088a 100644 --- a/.github/workflows/python-linux.yml +++ b/.github/workflows/python-linux.yml @@ -69,17 +69,17 @@ jobs: - name: Run the tests if: ${{ matrix.python-version != 'pypy3' }} run: | - pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered + pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered - name: Run the tests on pypy if: ${{ matrix.python-version == 'pypy3' }} run: | - pytest -vv + pytest -vv jupyter_server - name: Install the Python dependencies for the examples run: | cd examples/simple && pip install -e . - name: Run the tests for the examples run: | - pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD + pytest examples/simple - name: Coverage if: ${{ matrix.python-version != 'pypy3' }} run: | diff --git a/.github/workflows/python-macos.yml b/.github/workflows/python-macos.yml index 97741eeba1..bf5ee1b122 100644 --- a/.github/workflows/python-macos.yml +++ b/.github/workflows/python-macos.yml @@ -46,17 +46,17 @@ jobs: - name: Run the tests if: ${{ !startsWith( matrix.python-version, 'pypy' ) }} run: | - pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered + pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered - name: Run the tests on pypy if: ${{ startsWith( matrix.python-version, 'pypy' ) }} run: | - pytest -vv + pytest -vv jupyter_server - name: Install the Python dependencies for the examples run: | cd examples/simple && pip install -e . - name: Run the tests for the examples run: | - pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD + pytest examples/simple - name: Coverage if: ${{ !startsWith( matrix.python-version, 'pypy' ) }} run: | diff --git a/.github/workflows/python-windows.yml b/.github/workflows/python-windows.yml index 535e5735cf..bdb4560117 100644 --- a/.github/workflows/python-windows.yml +++ b/.github/workflows/python-windows.yml @@ -49,10 +49,10 @@ jobs: # the file descriptions opened by the asyncio IOLoop. # This leads to a nasty, flaky race condition that we haven't # been able to solve. - pytest -vv -s + pytest -vv -s jupyter_server - name: Install the Python dependencies for the examples run: | cd examples/simple && pip install -e . - name: Run the tests for the examples run: | - pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD + pytest examples/simple diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index b25be508d9..d21a3a12bd 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -85,12 +85,12 @@ Running Tests Install dependencies:: pip install -e .[test] - pip install -e examples/simple + pip install -e examples/simple # to test the examples To run the Python tests, use:: - pytest - pytest examples/simple --confcutdir=$PWD + pytest jupyter_server + pytest examples/simple # to test the examples Building the Docs ================= diff --git a/examples/simple/conftest.py b/examples/simple/conftest.py new file mode 100644 index 0000000000..1e1fa425e6 --- /dev/null +++ b/examples/simple/conftest.py @@ -0,0 +1 @@ +from jupyter_server.conftest import * diff --git a/conftest.py b/jupyter_server/conftest.py similarity index 100% rename from conftest.py rename to jupyter_server/conftest.py diff --git a/pyproject.toml b/pyproject.toml index a6eba65738..899726cdfd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ ignore = ["tbump.toml", ".*", "*.yml", "package-lock.json", "bootstrap*", "conft [tool.pytest.ini_options] addopts = "--doctest-modules" testpaths = [ - "jupyter_server" + "jupyter_server/" ] [tool.jupyter-releaser]