Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pandas/util/_tester.py: 43%

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

23 statements  

1""" 

2Entrypoint for testing from the top-level namespace. 

3""" 

4 

5from __future__ import annotations 

6 

7import os 

8import sys 

9 

10from pandas.compat._optional import import_optional_dependency 

11from pandas.util._decorators import set_module 

12 

13PKG = os.path.dirname(os.path.dirname(__file__)) 

14 

15 

16@set_module("pandas") 

17def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> None: # noqa: PT028 

18 """ 

19 Run the pandas test suite using pytest. 

20 

21 By default, runs with the marks -m "not slow and not network and not db" 

22 

23 Parameters 

24 ---------- 

25 extra_args : list[str], default None 

26 Extra marks to run the tests. 

27 run_doctests : bool, default False 

28 Whether to only run the Python and Cython doctests. If you would like to run 

29 both doctests/regular tests, just append "--doctest-modules"/"--doctest-cython" 

30 to extra_args. 

31 

32 See Also 

33 -------- 

34 pytest.main : The main entry point for pytest testing framework. 

35 

36 Examples 

37 -------- 

38 >>> pd.test() # doctest: +SKIP 

39 running: pytest... 

40 """ 

41 pytest = import_optional_dependency("pytest") 

42 import_optional_dependency("hypothesis") 

43 cmd = ["-m not slow and not network and not db"] 

44 if extra_args: 

45 if not isinstance(extra_args, list): 

46 extra_args = [extra_args] 

47 cmd = extra_args 

48 if run_doctests: 

49 cmd = [ 

50 "--doctest-modules", 

51 "--doctest-cython", 

52 f"--ignore={os.path.join(PKG, 'tests')}", 

53 ] 

54 cmd += [PKG] 

55 joined = " ".join(cmd) 

56 print(f"running: pytest {joined}") 

57 sys.exit(pytest.main(cmd)) 

58 

59 

60__all__ = ["test"]