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

Method test_metadata_present

tests/test_make.py:1893–1912  ·  view source on GitHub ↗

Assert dictionaries are copied and present.

(self, list_of_attrs)

Source from the content-addressed store, hash-verified

1891
1892 @given(sorted_lists_of_attrs)
1893 def test_metadata_present(self, list_of_attrs):
1894 """
1895 Assert dictionaries are copied and present.
1896 """
1897 C = make_class("C", dict(zip(gen_attr_names(), list_of_attrs)))
1898
1899 for hyp_attr, class_attr in zip(list_of_attrs, fields(C)):
1900 if hyp_attr.metadata is None:
1901 # The default is a singleton empty dict.
1902 assert class_attr.metadata is not None
1903 assert len(class_attr.metadata) == 0
1904 else:
1905 assert hyp_attr.metadata == class_attr.metadata
1906
1907 # Once more, just to assert getting items and iteration.
1908 for k in class_attr.metadata:
1909 assert hyp_attr.metadata[k] == class_attr.metadata[k]
1910 assert hyp_attr.metadata.get(k) == class_attr.metadata.get(
1911 k
1912 )
1913
1914 @given(simple_classes(), text())
1915 def test_metadata_immutability(self, C, string):

Callers

nothing calls this directly

Calls 3

make_classFunction · 0.90
fieldsFunction · 0.90
gen_attr_namesFunction · 0.85

Tested by

no test coverage detected