conftest.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. import pytest
  5. pytest_plugins = [
  6. "jupyter_server.pytest_plugin",
  7. "jupyterlab_server.pytest_plugin",
  8. "jupyterlab.pytest_plugin",
  9. ]
  10. def pytest_addoption(parser):
  11. """
  12. Adds flags for pytest.
  13. This is called by the pytest API
  14. """
  15. group = parser.getgroup("general")
  16. group.addoption("--quick", action="store_true", help="Skip slow tests")
  17. group.addoption("--slow", action="store_true", help="Run only slow tests")
  18. def pytest_configure(config):
  19. config.addinivalue_line("markers", "slow: mark test as slow to run")
  20. def pytest_collection_modifyitems(config, items):
  21. if config.getoption("--quick"):
  22. skip_slow = pytest.mark.skip(reason="skipping slow test")
  23. for item in items:
  24. if "slow" in item.keywords:
  25. item.add_marker(skip_slow)
  26. elif config.getoption("--slow"):
  27. skip_quick = pytest.mark.skip(reason="skipping non-slow test")
  28. for item in items:
  29. if "slow" not in item.keywords:
  30. item.add_marker(skip_quick)