Skip to content

Commit dd48b41

Browse files
author
gcerri
committed
Add unit tests for info() with return_dict=True
1 parent 0abc4f4 commit dd48b41

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pandas/tests/frame/methods/test_info.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,3 +569,28 @@ def test_info_show_counts(row, columns, show_counts, result):
569569
with StringIO() as buf:
570570
df.info(buf=buf, show_counts=show_counts)
571571
assert ("non-null" in buf.getvalue()) is result
572+
573+
@pytest.mark.parametrize(
574+
"df", [
575+
DataFrame({
576+
'A': [1, 2, 3],
577+
'B': [4, 5, 6]
578+
}),
579+
DataFrame({}),
580+
]
581+
)
582+
def test_info_return_dict(df):
583+
result = df.info(return_dict=True)
584+
expected_keys = {'Column_summary', 'Memory_usage', 'Index_type', 'Index_entries'}
585+
assert isinstance(result, dict)
586+
assert expected_keys.issubset(result.keys())
587+
588+
assert 'Column_summary' in result
589+
assert 'Memory_usage' in result
590+
assert 'Index_type' in result
591+
assert 'Index_entries' in result
592+
593+
assert isinstance(result['Column_summary'], list)
594+
assert isinstance(result['Memory_usage'], np.int64)
595+
assert isinstance(result['Index_type'], str)
596+
assert isinstance(result['Index_entries'], int)

0 commit comments

Comments
 (0)