zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
U
®ý°dÉã@sdZddlmZddlZddlmZddlZddlZddl    m
Z
ddl m Z ddl mZmZddlmZdd    lmZmZdd
lmZd9d d d œdd„Zddœdd„Zddœdd„Zddœdd„Zd dœdd„Zd:d d dœdd„ZejjeƒddZejjeƒ d dZ ejje d!dZ!ejjeƒd"dZ"ejjeƒd#e #¡d›dZ$ejjeƒd$dZ%ejje d%e›d&e›dZ&ddœd d d'œd(d)„Z'd*dœd+d,„Z(d-d.„Z)d/dœd0d1„Z*ejj+e
d2ƒd3kd4dZ,ejje
d2ƒd3kd5dZ-ejj+e
d6ƒd7dZ.ejje
d6ƒd8dZ/dS);aÂ
This module provides decorator functions which can be applied to test objects
in order to skip those objects when certain conditions occur. A sample use case
is to detect if the platform is missing ``matplotlib``. If so, any test objects
which require ``matplotlib`` and decorated with ``@td.skip_if_no_mpl`` will be
skipped by ``pytest`` during the execution of the test suite.
 
To illustrate, after importing this module:
 
import pandas.util._test_decorators as td
 
The decorators can be applied to classes:
 
@td.skip_if_some_reason
class Foo:
    ...
 
Or individual functions:
 
@td.skip_if_some_reason
def test_foo():
    ...
 
For more information, refer to the ``pytest`` documentation on ``skipif``.
é)Ú annotationsN)ÚCallable)Ú
get_option)ÚF)ÚIS64Úis_platform_windows)Úimport_optional_dependency)ÚNUMEXPR_INSTALLEDÚ USE_NUMEXPR)ÚVersionÚstrz
str | None)Úmod_nameÚ min_versioncCs¬z t|ƒ}Wn8tk
r"YdStk
rD|dkr>YdS‚YnX|sN|Sddl}zt|j|dƒ}Wn$tk
rŽt|j|dƒ}YnX|r¨t|ƒt|ƒkr¨|SdS)a
    Parameters
    ----------
    mod_name : str
        Name of the module to be imported
    min_version : str, default None
        Minimum required version of the specified mod_name
 
    Returns
    -------
    object
        The imported module if successful, or False
    FZnumbarNÚ __version__Z __VERSION__)Ú
__import__Ú ImportErrorÚ SystemErrorÚsysÚgetattrÚmodulesÚAttributeErrorr )r rÚmodrÚversion©rúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/util/_test_decorators.pyÚ safe_import2s$ rÚbool)ÚreturncCs"tdƒ}|r| d¡dSdSdS)NZ
matplotlibZAggFT)rZuse)rrrrÚ_skip_if_no_mpl\s
 
rcCst ¡\}}|dkrdSdS)NÚen_USTF)ÚlocaleÚ    getlocale)ÚlangÚ_rrrÚ_skip_if_not_us_localees r$cCs"tdƒotdƒotdƒotdƒ S)Nz scipy.statsz scipy.sparsezscipy.interpolatez scipy.signal)rrrrrÚ_skip_if_no_scipylsÿþür%©ÚpackagecCstjjt|ƒd|›ddS)z‚
    Skip a test if a package is installed.
 
    Parameters
    ----------
    package : str
        The name of the package.
    zSkipping because z is installed.©Úreason©ÚpytestÚmarkÚskipifrr&rrrÚskip_if_installedws    
ÿr.)r'rcCs8d|›d}|r|d|›7}tjjt||d |dS)aù
    Generic function to help skip tests when required packages are not
    present on the testing system.
 
    This function returns a pytest mark with a skip condition that will be
    evaluated during test collection. An attempt will be made to import the
    specified ``package`` and optionally ensure it meets the ``min_version``
 
    The mark can be used as either a decorator for a test function or to be
    applied to parameters in pytest.mark.parametrize calls or parametrized
    fixtures.
 
    If the import and version check are unsuccessful, then the test function
    (or test case when used in conjunction with parametrization) will be
    skipped.
 
    Parameters
    ----------
    package: str
        The name of the required package.
    min_version: str or None, default None
        Optional minimum version of the package.
 
    Returns
    -------
    _pytest.mark.structures.MarkDecorator
        a pytest.mark.skipif to use as either a test decorator or a
        parametrization mark.
    zCould not import 'ú'z satisfying a min_version of )rr(r*)r'rÚmsgrrrÚ
skip_if_no‡s  ÿr1zMissing matplotlib dependencyr(zmatplotlib is presentzskipping for 32 bitzRunning on WindowszSpecific locale is set zMissing SciPy requirementznumexpr enabled->z , installed->)Úver_strr)cGs:|dkrd|›d}tjjttjƒt|ƒkf|žd|iŽS)NzNumPy z or greater requiredr))r+r,r-r Únpr)r2r)ÚargsrrrÚ skip_if_np_ltÂs ÿþýr5zCallable[[F], F]cs‡fdd„}|S)a
    Intended for use as a decorator for parametrized fixture,
    this function will wrap the decorated function with a pytest
    ``parametrize_fixture_doc`` mark. That mark will format
    initial fixture docstring by replacing placeholders {0}, {1} etc
    with parameters passed as arguments.
 
    Parameters
    ----------
    args: iterable
        Positional arguments for docstring.
 
    Returns
    -------
    function
        The decorated function wrapped within a pytest
        ``parametrize_fixture_doc`` mark
    cs|jjˆŽ|_|S)N)Ú__doc__Úformat)Zfixture©r4rrÚdocumented_fixtureàsz3parametrize_fixture_doc.<locals>.documented_fixturer)r4r9rr8rÚparametrize_fixture_docÌs r:cCs<ztdƒtjj}Wn"tk
r6tjjdd}YnX|S)NZpytest_asyncioz!Missing dependency pytest-asyncior()rr+r,ZasynciorÚskip)Ú
async_markrrrr<çs  r<ÚNonecCstjjdd}|j |¡dS)Nú$Not yet implemented for ArrayManagerr()r+r,ÚxfailÚnodeZ
add_marker)Úrequestr,rrrÚ&mark_array_manager_not_yet_implementedñsrBzmode.data_managerÚarrayr>z@Test that relies on BlockManager internals or specific behaviourzmode.copy_on_writez2Not yet implemented/adapted for Copy-on-Write modez%Test not valid for Copy-on-Write mode)N)N)0r6Ú
__future__rr ÚtypingrÚnumpyr3r+Zpandas._configrZpandas._typingrZ pandas.compatrrZpandas.compat._optionalrZ#pandas.core.computation.expressionsr    r
Zpandas.util.versionr rrr$r%r.r1r,r-Zskip_if_no_mplZ skip_if_mplZ skip_if_32bitZskip_if_windowsr!Zskip_if_not_us_localeZskip_if_no_scipyZ skip_if_no_ner5r:r<rBr?Z&skip_array_manager_not_yet_implementedZskip_array_manager_invalid_testZ&skip_copy_on_write_not_yet_implementedZskip_copy_on_write_invalid_testrrrrÚ<module>sp      *     &ÿþÿþ
 
 
þ
þþþ