MCPcopy Create free account
hub / github.com/ipython/traitlets / test_traits_metadata

Method test_traits_metadata

tests/test_traitlets.py:871–885  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

869 self.assertEqual(A.class_traits(), dict(i=A.i, f=A.f))
870
871 def test_traits_metadata(self):
872 class A(HasTraits):
873 i = Int().tag(config_key="VALUE1", other_thing="VALUE2")
874 f = Float().tag(config_key="VALUE3", other_thing="VALUE2")
875 j = Int(0)
876
877 a = A()
878 self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j))
879 traits = a.traits(config_key="VALUE1", other_thing="VALUE2")
880 self.assertEqual(traits, dict(i=A.i))
881
882 # This passes, but it shouldn't because I am replicating a bug in
883 # traits.
884 traits = a.traits(config_key=lambda v: True)
885 self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j))
886
887 def test_traits_metadata_deprecated(self):
888 with expected_warnings([r"metadata should be set using the \.tag\(\) method"] * 2):

Callers

nothing calls this directly

Calls 2

traitsMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected