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

Method test_factory

tests/test_dunders.py:827–845  ·  view source on GitHub ↗

If a default factory is present, it's used as fallback.

(self)

Source from the content-addressed store, hash-verified

825 assert None is i.c
826
827 def test_factory(self):
828 """
829 If a default factory is present, it's used as fallback.
830 """
831
832 class D:
833 pass
834
835 class C:
836 __attrs_attrs__ = [
837 simple_attr(name="a", default=Factory(list)),
838 simple_attr(name="b", default=Factory(D)),
839 ]
840
841 C = _add_init(C, False)
842 i = C()
843
844 assert [] == i.a
845 assert isinstance(i.b, D)
846
847 def test_factory_takes_self(self):
848 """

Callers

nothing calls this directly

Calls 2

_add_initFunction · 0.85
CClass · 0.70

Tested by

no test coverage detected