@@ -38,6 +38,7 @@ def get_captured_output(capsys):
38
38
)
39
39
@pytest .mark .filterwarnings ("ignore:Setuptools is replacing distutils:UserWarning" )
40
40
def test_show_versions (tmpdir ):
41
+ # GH39701
41
42
as_json = os .path .join (tmpdir , "test_output.json" )
42
43
43
44
pd .show_versions (as_json = as_json )
@@ -56,11 +57,12 @@ def test_show_versions(tmpdir):
56
57
57
58
58
59
def test_show_versions_console_json (capsys ):
60
+ # GH39701
59
61
pd .show_versions (as_json = True )
60
- result = get_captured_output ( capsys )
62
+ stdout = capsys . readouterr (). out
61
63
62
64
# check valid json is printed to the console if as_json is True
63
- result = json .loads (result )
65
+ result = json .loads (stdout )
64
66
65
67
# Basic check that each version element is found in output
66
68
expected = {
@@ -73,8 +75,9 @@ def test_show_versions_console_json(capsys):
73
75
74
76
def test_show_versions_console (capsys ):
75
77
# gh-32041
78
+ # GH39701
76
79
pd .show_versions (as_json = False )
77
- result = get_captured_output ( capsys )
80
+ result = capsys . readouterr (). out
78
81
79
82
# check header
80
83
assert "INSTALLED VERSIONS" in result
@@ -91,8 +94,9 @@ def test_show_versions_console(capsys):
91
94
92
95
93
96
def test_json_output_match (capsys , tmpdir ):
97
+ # GH39701
94
98
pd .show_versions (as_json = True )
95
- result_console = get_captured_output ( capsys )
99
+ result_console = capsys . readouterr (). out
96
100
97
101
out_path = os .path .join (tmpdir , "test_json.json" )
98
102
pd .show_versions (as_json = out_path )
0 commit comments