File tree 3 files changed +28
-6
lines changed
3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ def test_xlrd_version_fallback():
22
22
import_optional_dependency ("xlrd" )
23
23
24
24
25
- def test_bad_version ():
25
+ def test_bad_version (monkeypatch ):
26
26
name = "fakemodule"
27
27
module = types .ModuleType (name )
28
28
module .__version__ = "0.9.0"
29
29
sys .modules [name ] = module
30
- VERSIONS [ name ] = "1.0.0"
30
+ monkeypatch . setitem ( VERSIONS , name , "1.0.0" )
31
31
32
32
match = "Pandas requires .*1.0.0.* of .fakemodule.*'0.9.0'"
33
33
with pytest .raises (ImportError , match = match ):
@@ -42,11 +42,11 @@ def test_bad_version():
42
42
assert result is module
43
43
44
44
45
- def test_no_version_raises ():
45
+ def test_no_version_raises (monkeypatch ):
46
46
name = "fakemodule"
47
47
module = types .ModuleType (name )
48
48
sys .modules [name ] = module
49
- VERSIONS [ name ] = "1.0.0"
49
+ monkeypatch . setitem ( VERSIONS , name , "1.0.0" )
50
50
51
51
with pytest .raises (ImportError , match = "Can't determine .* fakemodule" ):
52
52
import_optional_dependency (name )
Original file line number Diff line number Diff line change
1
+ import re
2
+
3
+ import pandas as pd
4
+
5
+
6
+ def test_show_versions (capsys ):
7
+ # gh-32041
8
+ pd .show_versions ()
9
+ captured = capsys .readouterr ()
10
+ result = captured .out
11
+
12
+ # check header
13
+ assert "INSTALLED VERSIONS" in result
14
+
15
+ # check full commit hash
16
+ assert re .search (r"commit\s*:\s[0-9a-f]{40}\n" , result )
17
+
18
+ # check required dependency
19
+ assert re .search (r"numpy\s*:\s([0-9\.\+a-f]|dev)+\n" , result )
20
+
21
+ # check optional dependency
22
+ assert re .search (r"pyarrow\s*:\s([0-9\.]+|None)\n" , result )
Original file line number Diff line number Diff line change @@ -118,10 +118,10 @@ def show_versions(as_json=False):
118
118
print ("\n INSTALLED VERSIONS" )
119
119
print ("------------------" )
120
120
for k , stat in sys_info :
121
- print (f"{{ k:<{ maxlen } }} : {{ stat} }" )
121
+ print (f"{ k :<{maxlen }} : { stat } " )
122
122
print ("" )
123
123
for k , stat in deps_blob :
124
- print (f"{{ k:<{ maxlen } }} : {{ stat} }" )
124
+ print (f"{ k :<{maxlen }} : { stat } " )
125
125
126
126
127
127
def main () -> int :
You can’t perform that action at this time.
0 commit comments