Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/tests/test_optional_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def test_xlrd_version_fallback():
import_optional_dependency("xlrd")


def test_bad_version():
def test_bad_version(monkeypatch):
name = "fakemodule"
module = types.ModuleType(name)
module.__version__ = "0.9.0"
sys.modules[name] = module
VERSIONS[name] = "1.0.0"
monkeypatch.setitem(VERSIONS, name, "1.0.0")

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


def test_no_version_raises():
def test_no_version_raises(monkeypatch):
name = "fakemodule"
module = types.ModuleType(name)
sys.modules[name] = module
VERSIONS[name] = "1.0.0"
monkeypatch.setitem(VERSIONS, name, "1.0.0")

with pytest.raises(ImportError, match="Can't determine .* fakemodule"):
import_optional_dependency(name)
22 changes: 22 additions & 0 deletions pandas/tests/util/test_show_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import re

import pandas as pd


def test_show_versions(capsys):
# gh-32041
pd.show_versions()
captured = capsys.readouterr()
result = captured.out

# check header
assert "INSTALLED VERSIONS" in result

# check full commit hash
assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)

# check required dependency
assert re.search(r"numpy\s*:\s([0-9\.\+a-f]|dev)+\n", result)

# check optional dependency
assert re.search(r"pyarrow\s*:\s([0-9\.]+|None)\n", result)
4 changes: 2 additions & 2 deletions pandas/util/_print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def show_versions(as_json=False):
print("\nINSTALLED VERSIONS")
print("------------------")
for k, stat in sys_info:
print(f"{{k:<{maxlen}}}: {{stat}}")
print(f"{k:<{maxlen}}: {stat}")
print("")
for k, stat in deps_blob:
print(f"{{k:<{maxlen}}}: {{stat}}")
print(f"{k:<{maxlen}}: {stat}")


def main() -> int:
Expand Down