Skip to content

Commit 2773e1e

Browse files
committed
checking that we are not modifiying the value
1 parent 6e1ae67 commit 2773e1e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_summarize.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
from deepdiff.summarize import summarize, _truncate
23

34

@@ -105,18 +106,22 @@ def test_nested_structure_summary1(self):
105106
}
106107
]
107108
}
108-
summary = summarize(data, max_length=200)
109+
data_copy = deepcopy(data)
110+
summary = summarize(data_copy, max_length=200)
109111
assert len(summary) <= 200
110112
# Check that some expected keys are in the summary
111113
assert '"RecordType"' in summary
112114
assert '"RecordNumber"' in summary
113115
assert '"RecordTitle"' in summary
114116
assert '{"RecordType":,"RecordNumber":,"RecordTitle":","Section":[{"TOCHeading":","Description":"St...d","Section":[{"TOCHeading":","Description":"A t,"DisplayControls":{"Information":[{}]},...]},...]}' == summary
117+
assert data_copy == data, "We should not have modified the original data"
115118

116119
def test_nested_structure_summary2(self, compounds):
117120
summary = summarize(compounds, max_length=200)
118121
assert len(summary) <= 200
122+
data_copy = deepcopy(compounds)
119123
assert '{"RecordType":,"RecordNumber":,"RecordTitle":,"Section":[{"TOCHeading":,"Description":"Stru,"Section":[{"TOCHeading":"2D S,"DisplayControls":{}},...]},...],"Reference":[{},...]}' == summary
124+
assert data_copy == compounds, "We should not have modified the original data"
120125

121126
def test_list_summary(self):
122127
data = [1, 2, 3, 4]

0 commit comments

Comments
 (0)