Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.9/dist-packages/pandas/util/_tester.py: 35%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Entrypoint for testing from the top-level namespace.
3"""
4from __future__ import annotations
6import os
7import sys
9from pandas.compat._optional import import_optional_dependency
11PKG = os.path.dirname(os.path.dirname(__file__))
14def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> None:
15 """
16 Run the pandas test suite using pytest.
18 By default, runs with the marks -m "not slow and not network and not db"
20 Parameters
21 ----------
22 extra_args : list[str], default None
23 Extra marks to run the tests.
24 run_doctests : bool, default False
25 Whether to only run the Python and Cython doctests. If you would like to run
26 both doctests/regular tests, just append "--doctest-modules"/"--doctest-cython"
27 to extra_args.
29 Examples
30 --------
31 >>> pd.test() # doctest: +SKIP
32 running: pytest...
33 """
34 pytest = import_optional_dependency("pytest")
35 import_optional_dependency("hypothesis")
36 cmd = ["-m not slow and not network and not db"]
37 if extra_args:
38 if not isinstance(extra_args, list):
39 extra_args = [extra_args]
40 cmd = extra_args
41 if run_doctests:
42 cmd = [
43 "--doctest-modules",
44 "--doctest-cython",
45 f"--ignore={os.path.join(PKG, 'tests')}",
46 ]
47 cmd += [PKG]
48 joined = " ".join(cmd)
49 print(f"running: pytest {joined}")
50 sys.exit(pytest.main(cmd))
53__all__ = ["test"]