Skip to content

Commit 7cd411b

Browse files
committed
BUG: Various test improvements to test_show_versions (pandas-dev#39701)
1 parent 23d34c9 commit 7cd411b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/tests/util/test_show_versions.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def get_captured_output(capsys):
3838
)
3939
@pytest.mark.filterwarnings("ignore:Setuptools is replacing distutils:UserWarning")
4040
def test_show_versions(tmpdir):
41+
# GH39701
4142
as_json = os.path.join(tmpdir, "test_output.json")
4243

4344
pd.show_versions(as_json=as_json)
@@ -56,11 +57,12 @@ def test_show_versions(tmpdir):
5657

5758

5859
def test_show_versions_console_json(capsys):
60+
# GH39701
5961
pd.show_versions(as_json=True)
60-
result = get_captured_output(capsys)
62+
stdout = capsys.readouterr().out
6163

6264
# check valid json is printed to the console if as_json is True
63-
result = json.loads(result)
65+
result = json.loads(stdout)
6466

6567
# Basic check that each version element is found in output
6668
expected = {
@@ -73,8 +75,9 @@ def test_show_versions_console_json(capsys):
7375

7476
def test_show_versions_console(capsys):
7577
# gh-32041
78+
# GH39701
7679
pd.show_versions(as_json=False)
77-
result = get_captured_output(capsys)
80+
result = capsys.readouterr().out
7881

7982
# check header
8083
assert "INSTALLED VERSIONS" in result
@@ -91,8 +94,9 @@ def test_show_versions_console(capsys):
9194

9295

9396
def test_json_output_match(capsys, tmpdir):
97+
# GH39701
9498
pd.show_versions(as_json=True)
95-
result_console = get_captured_output(capsys)
99+
result_console = capsys.readouterr().out
96100

97101
out_path = os.path.join(tmpdir, "test_json.json")
98102
pd.show_versions(as_json=out_path)

0 commit comments

Comments
 (0)