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

Method test_traits_metadata_deprecated

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

Source from the content-addressed store, hash-verified

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):
889
890 class A(HasTraits):
891 i = Int(config_key="VALUE1", other_thing="VALUE2")
892 f = Float(config_key="VALUE3", other_thing="VALUE2")
893 j = Int(0)
894
895 a = A()
896 self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j))
897 traits = a.traits(config_key="VALUE1", other_thing="VALUE2")
898 self.assertEqual(traits, dict(i=A.i))
899
900 # This passes, but it shouldn't because I am replicating a bug in
901 # traits.
902 traits = a.traits(config_key=lambda v: True)
903 self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j))
904
905 def test_init(self):
906 class A(HasTraits):

Callers

nothing calls this directly

Calls 3

expected_warningsFunction · 0.85
traitsMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected