File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2068,6 +2068,24 @@ def test_attributes_copied(self):
20682068 # attributes dict of old table not be changed since new dist is a copy
20692069 self .assertDictEqual (self .table .attributes , {"A" : "Test" , "B" : []})
20702070
2071+ def test_attributes_copied_once (self ):
2072+ A = Mock ()
2073+ A .__deepcopy__ = Mock ()
2074+ self .table .attributes = {"A" : A }
2075+
2076+ # a single direct transformation
2077+ self .table .from_table (self .table .domain , self .table )
2078+ self .assertEqual (1 , A .__deepcopy__ .call_count )
2079+ A .__deepcopy__ .reset_mock ()
2080+
2081+ # hierarchy of transformations
2082+ ndom = Domain ([a .copy (compute_value = lambda x : x .transform (Domain ([a ])))
2083+ for a in self .table .domain .attributes ])
2084+ self .table .from_table (ndom , self .table )
2085+ self .assertEqual (1 , A .__deepcopy__ .call_count )
2086+ # HISTORIC: before only the outermost transformation deepcopied the
2087+ # attributes, here were 23 calls to __deepcopy__ instead of 1
2088+
20712089
20722090def isspecial (s ):
20732091 return isinstance (s , slice ) or s is Ellipsis
You can’t perform that action at this time.
0 commit comments