conftest.py 1.1 KB

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