Skip to content

Commit ac3056f

Browse files
REGR: show_versions (#32041)
1 parent 3cb81ea commit ac3056f

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

Diff for: pandas/tests/test_optional_dependency.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ def test_xlrd_version_fallback():
2222
import_optional_dependency("xlrd")
2323

2424

25-
def test_bad_version():
25+
def test_bad_version(monkeypatch):
2626
name = "fakemodule"
2727
module = types.ModuleType(name)
2828
module.__version__ = "0.9.0"
2929
sys.modules[name] = module
30-
VERSIONS[name] = "1.0.0"
30+
monkeypatch.setitem(VERSIONS, name, "1.0.0")
3131

3232
match = "Pandas requires .*1.0.0.* of .fakemodule.*'0.9.0'"
3333
with pytest.raises(ImportError, match=match):
@@ -42,11 +42,11 @@ def test_bad_version():
4242
assert result is module
4343

4444

45-
def test_no_version_raises():
45+
def test_no_version_raises(monkeypatch):
4646
name = "fakemodule"
4747
module = types.ModuleType(name)
4848
sys.modules[name] = module
49-
VERSIONS[name] = "1.0.0"
49+
monkeypatch.setitem(VERSIONS, name, "1.0.0")
5050

5151
with pytest.raises(ImportError, match="Can't determine .* fakemodule"):
5252
import_optional_dependency(name)

Diff for: pandas/tests/util/test_show_versions.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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)

Diff for: pandas/util/_print_versions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def show_versions(as_json=False):
118118
print("\nINSTALLED VERSIONS")
119119
print("------------------")
120120
for k, stat in sys_info:
121-
print(f"{{k:<{maxlen}}}: {{stat}}")
121+
print(f"{k:<{maxlen}}: {stat}")
122122
print("")
123123
for k, stat in deps_blob:
124-
print(f"{{k:<{maxlen}}}: {{stat}}")
124+
print(f"{k:<{maxlen}}: {stat}")
125125

126126

127127
def main() -> int:

0 commit comments

Comments
 (0)