_tester.py 712 B

1234567891011121314151617181920212223242526272829
  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:
  11. raise ImportError("Need pytest>=3.0 to run tests")
  12. try:
  13. import hypothesis # noqa
  14. except ImportError:
  15. raise ImportError("Need hypothesis>=3.58 to run tests")
  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. print("running: pytest {}".format(' '.join(cmd)))
  23. sys.exit(pytest.main(cmd))
  24. __all__ = ['test']