_tester.py 759 B

123456789101112131415161718192021222324252627282930
  1. """
  2. Entrypoint for testing from the top-level namespace.
  3. """
  4. import os
  5. import sys
  6. PKG = os.path.dirname(os.path.dirname(__file__))
  7. def test(extra_args=None):
  8. try:
  9. import pytest
  10. except ImportError as err:
  11. raise ImportError("Need pytest>=5.0.1 to run tests") from err
  12. try:
  13. import hypothesis # noqa
  14. except ImportError as err:
  15. raise ImportError("Need hypothesis>=3.58 to run tests") from err
  16. cmd = ["--skip-slow", "--skip-network", "--skip-db"]
  17. if extra_args:
  18. if not isinstance(extra_args, list):
  19. extra_args = [extra_args]
  20. cmd = extra_args
  21. cmd += [PKG]
  22. joined = " ".join(cmd)
  23. print(f"running: pytest {joined}")
  24. sys.exit(pytest.main(cmd))
  25. __all__ = ["test"]