Skip to content

Commit 1c1e9a8

Browse files
author
y-p
committed
TST: pathological objects cause infinite loop when passed to pprint_thing
1 parent afba0d0 commit 1c1e9a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/test_format.py

+12
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,18 @@ def test_to_html_with_classes(self):
10761076
result = df.to_html(classes=["sortable", "draggable"])
10771077
self.assertEqual(result, expected)
10781078

1079+
def test_pprint_pathological_object(self):
1080+
"""
1081+
if the test fails, the stack will overflow and nose crash,
1082+
but it won't hang.
1083+
"""
1084+
class A:
1085+
def __getitem__(self, key):
1086+
return 3 # obviously simplified
1087+
self.assertTrue("A instance" in repr(A()) )
1088+
df = pandas.DataFrame([A()])
1089+
repr(df) # just don't dine
1090+
10791091
def test_float_trim_zeros(self):
10801092
vals = [2.08430917305e+10, 3.52205017305e+10, 2.30674817305e+10,
10811093
2.03954217305e+10, 5.59897817305e+10]

0 commit comments

Comments
 (0)