20
20
__date__ = "2/14/13"
21
21
22
22
23
- class StructureNLCase (TestCase ):
23
+ class TestStructureNL (TestCase ):
24
24
def setUp (self ):
25
25
# set up a Structure
26
26
self .struct = Structure (np .eye (3 , 3 ) * 3 , ["Fe" ], [[0 , 0 , 0 ]])
@@ -214,8 +214,14 @@ def test_as_from_dict(self):
214
214
{"_my_data" : "string" },
215
215
[self .valid_node , self .valid_node2 ],
216
216
)
217
- b = StructureNL .from_dict (struct_nl .as_dict ())
218
- assert struct_nl == b
217
+ round_trip_from_dict = StructureNL .from_dict (struct_nl .as_dict ())
218
+ needed_attrs = ("structure" , "authors" , "projects" , "references" , "remarks" , "data" , "history" , "created_at" )
219
+ for attr in needed_attrs :
220
+ print (f"{ attr } ={ getattr (struct_nl , attr )} " )
221
+ print (f"{ getattr (round_trip_from_dict , attr )= } " )
222
+ print (f"{ round_trip_from_dict = } " )
223
+ print (f"{ struct_nl = } " )
224
+ assert struct_nl == round_trip_from_dict
219
225
# complicated objects in the 'data' and 'nodes' field
220
226
complicated_node = {
221
227
"name" : "complicated node" ,
@@ -231,15 +237,15 @@ def test_as_from_dict(self):
231
237
{"_my_data" : {"structure" : self .s2 }},
232
238
[complicated_node , self .valid_node ],
233
239
)
234
- b = StructureNL .from_dict (struct_nl .as_dict ())
240
+ round_trip_from_dict = StructureNL .from_dict (struct_nl .as_dict ())
235
241
assert (
236
- struct_nl == b
242
+ struct_nl == round_trip_from_dict
237
243
), "to/from dict is broken when object embedding is used! Apparently MontyEncoding is broken..."
238
244
239
245
# Test molecule
240
246
mol_nl = StructureNL (self .mol , self .hulk , references = self .pmg )
241
- b = StructureNL .from_dict (mol_nl .as_dict ())
242
- assert mol_nl == b
247
+ round_trip_from_dict = StructureNL .from_dict (mol_nl .as_dict ())
248
+ assert mol_nl == round_trip_from_dict
243
249
244
250
def test_from_structures (self ):
245
251
s1 = Structure (np .eye (3 ) * 5 , ["Fe" ], [[0 , 0 , 0 ]])
0 commit comments