_tester.py 949 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """
  2. Entrypoint for testing from the top-level namespace.
  3. """
  4. from __future__ import annotations
  5. import os
  6. import sys
  7. from pandas.compat._optional import import_optional_dependency
  8. PKG = os.path.dirname(os.path.dirname(__file__))
  9. def test(extra_args: list[str] | None = None) -> None:
  10. """
  11. Run the pandas test suite using pytest.
  12. By default, runs with the marks --skip-slow, --skip-network, --skip-db
  13. Parameters
  14. ----------
  15. extra_args : list[str], default None
  16. Extra marks to run the tests.
  17. """
  18. pytest = import_optional_dependency("pytest")
  19. import_optional_dependency("hypothesis")
  20. cmd = ["--skip-slow", "--skip-network", "--skip-db"]
  21. if extra_args:
  22. if not isinstance(extra_args, list):
  23. extra_args = [extra_args]
  24. cmd = extra_args
  25. cmd += [PKG]
  26. joined = " ".join(cmd)
  27. print(f"running: pytest {joined}")
  28. sys.exit(pytest.main(cmd))
  29. __all__ = ["test"]