File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import subprocess
1
2
import sys
2
3
from typing import List
3
4
5
+ import pytest
6
+
4
7
import pandas as pd
5
8
from pandas import api , compat
6
9
import pandas ._testing as tm
@@ -311,3 +314,18 @@ def test_util_testing_deprecated_direct(self):
311
314
312
315
assert "pandas.util.testing is deprecated" in str (m [0 ].message )
313
316
assert "pandas.testing instead" in str (m [0 ].message )
317
+
318
+ def test_util_in_top_level (self ):
319
+ # in a subprocess to avoid import caching issues
320
+ out = subprocess .check_output (
321
+ [
322
+ sys .executable ,
323
+ "-c" ,
324
+ "import pandas; pandas.util.testing.assert_series_equal" ,
325
+ ],
326
+ stderr = subprocess .STDOUT ,
327
+ ).decode ()
328
+ assert "pandas.util.testing is deprecated" in out
329
+
330
+ with pytest .raises (AttributeError , match = "foo" ):
331
+ pd .util .foo
Original file line number Diff line number Diff line change 1
1
from pandas .util ._decorators import Appender , Substitution , cache_readonly # noqa
2
2
3
+ from pandas import compat
3
4
from pandas .core .util .hashing import hash_array , hash_pandas_object # noqa
5
+
6
+ # compatibility for import pandas; pandas.util.testing
7
+
8
+ if compat .PY37 :
9
+
10
+ def __getattr__ (name ):
11
+ if name == "testing" :
12
+ import pandas .util .testing
13
+
14
+ return pandas .util .testing
15
+ else :
16
+ raise AttributeError (f"module 'pandas.util' has no attribute '{ name } '" )
17
+
18
+
19
+ else :
20
+
21
+ class _testing :
22
+ def __getattr__ (self , item ):
23
+ import pandas .util .testing
24
+
25
+ return getattr (pandas .util .testing , item )
26
+
27
+ testing = _testing ()
28
+
29
+
30
+ del compat
You can’t perform that action at this time.
0 commit comments