Skip to content

Commit

Permalink
tests: fix downstream tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jun 30, 2021
1 parent 64bfe16 commit a739641
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
Expand All @@ -22,11 +23,14 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip
pip install ".[test]"
pip install "."
pip install --pre --upgrade jupyterlab_server[test] jupyterlab[test] nbclassic[test]
pip freeze
- name: Run tests
working-directory: ../
run: |
# NOTE: tests won't pass from inside the working copy because of
# conftest.py:pytest_plugins (must be at the top level)
pytest --pyargs jupyterlab_server
python -m jupyterlab.browser_check --no-browser-test
Expand Down
28 changes: 0 additions & 28 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
import pytest

pytest_plugins = [
"jupyter_server.pytest_plugin"
]

def pytest_addoption(parser):
parser.addoption(
"--integration_tests",
default=False,
type=bool,
help="only run tests with the 'integration_test' pytest mark.",
)


def pytest_configure(config):
# register an additional marker
config.addinivalue_line(
"markers", "integration_test"
)


def pytest_runtest_setup(item):
is_integration_test = any([mark for mark in item.iter_markers(name="integration_test")])

if item.config.getoption("--integration_tests") is True:
if not is_integration_test:
pytest.skip("Only running tests marked as 'integration_test'.")
else:
if is_integration_test:
pytest.skip("Skipping this test because it's marked 'integration_test'. Run integration tests using the `--integration_tests` flag.")
27 changes: 27 additions & 0 deletions jupyter_server/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

def pytest_addoption(parser):
parser.addoption(
"--integration_tests",
default=False,
type=bool,
help="only run tests with the 'integration_test' pytest mark.",
)


def pytest_configure(config):
# register an additional marker
config.addinivalue_line(
"markers", "integration_test"
)


def pytest_runtest_setup(item):
is_integration_test = any([mark for mark in item.iter_markers(name="integration_test")])

if item.config.getoption("--integration_tests") is True:
if not is_integration_test:
pytest.skip("Only running tests marked as 'integration_test'.")
else:
if is_integration_test:
pytest.skip("Skipping this test because it's marked 'integration_test'. Run integration tests using the `--integration_tests` flag.")

0 comments on commit a739641

Please sign in to comment.