conftest.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 py.test.
  13. This is called by the pytest API
  14. """
  15. group = parser.getgroup("general")
  16. group.addoption('--quick', action='store_true',
  17. help="Skip slow tests")
  18. group.addoption('--slow', action='store_true',
  19. help="Run only slow tests")
  20. def pytest_configure(config):
  21. config.addinivalue_line("markers", "slow: mark test as slow to run")
  22. def pytest_collection_modifyitems(config, items):
  23. if config.getoption("--quick"):
  24. skip_slow = pytest.mark.skip(reason="skipping slow test")
  25. for item in items:
  26. if "slow" in item.keywords:
  27. item.add_marker(skip_slow)
  28. elif config.getoption("--slow"):
  29. skip_quick = pytest.mark.skip(reason="skipping non-slow test")
  30. for item in items:
  31. if "slow" not in item.keywords:
  32. item.add_marker(skip_quick)