Skip to content

Commit 86a1404

Browse files
committed
TST: Test saves and restore context (#9764)
1 parent e375dd7 commit 86a1404

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/tests/test_format.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2987,7 +2987,13 @@ def test_format(self):
29872987
self.assertEqual(result[1], " 0")
29882988

29892989
def test_output_significant_digits(self):
2990-
# relevant to issue #9764
2990+
# Issue #9764
2991+
2992+
# In case default display precision changes:
2993+
saved_option=pd.get_option('display.precision')
2994+
pd.set_option('display.precision', 7)
2995+
2996+
# DataFrame from issue #9764
29912997
d=pd.DataFrame({'col1':[9.999e-8, 1e-7, 1.0001e-7, 2e-7, 4.999e-7, 5e-7, 5.0001e-7, 6e-7, 9.999e-7, 1e-6, 1.0001e-6, 2e-6, 4.999e-6, 5e-6, 5.0001e-6, 6e-6]})
29922998

29932999
expected_output={
@@ -3001,6 +3007,9 @@ def test_output_significant_digits(self):
30013007
for k, v in expected_output.items():
30023008
self.assertEqual(d[k[0]:k[1]].__str__(), v)
30033009

3010+
# Restore precision
3011+
pd.set_option('display.precision', saved_option)
3012+
30043013
class TestRepr_timedelta64(tm.TestCase):
30053014

30063015
def test_none(self):

0 commit comments

Comments
 (0)