MCPcopy
hub / github.com/python-attrs/attrs / test_recurse_property

Method test_recurse_property

tests/test_funcs.py:323–338  ·  view source on GitHub ↗

Property tests for recursive astuple.

(self, cls, tuple_class)

Source from the content-addressed store, hash-verified

321
322 @given(nested_classes, st.sampled_from(SEQUENCE_TYPES))
323 def test_recurse_property(self, cls, tuple_class):
324 """
325 Property tests for recursive astuple.
326 """
327 obj = cls()
328 obj_tuple = astuple(obj, tuple_factory=tuple_class)
329
330 def assert_proper_tuple_class(obj, obj_tuple):
331 assert isinstance(obj_tuple, tuple_class)
332 for index, field in enumerate(fields(obj.__class__)):
333 field_val = getattr(obj, field.name)
334 if has(field_val.__class__):
335 # This field holds a class, recurse the assertions.
336 assert_proper_tuple_class(field_val, obj_tuple[index])
337
338 assert_proper_tuple_class(obj, obj_tuple)
339
340 @given(nested_classes, st.sampled_from(SEQUENCE_TYPES))
341 def test_recurse_retain(self, cls, tuple_class):

Callers

nothing calls this directly

Calls 1

astupleFunction · 0.90

Tested by

no test coverage detected