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

Method test_args_kw

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

Source from the content-addressed store, hash-verified

1124 self.assertTrue(a.inst is not b.inst)
1125
1126 def test_args_kw(self):
1127 class Foo:
1128 def __init__(self, c):
1129 self.c = c
1130
1131 class Bar:
1132 pass
1133
1134 class Bah:
1135 def __init__(self, c, d):
1136 self.c = c
1137 self.d = d
1138
1139 class A(HasTraits):
1140 inst = Instance(Foo, (10,))
1141
1142 a = A()
1143 self.assertEqual(a.inst.c, 10)
1144
1145 class B(HasTraits):
1146 inst = Instance(Bah, args=(10,), kw=dict(d=20))
1147
1148 b = B()
1149 self.assertEqual(b.inst.c, 10)
1150 self.assertEqual(b.inst.d, 20)
1151
1152 class C(HasTraits):
1153 inst = Instance(Foo, allow_none=True)
1154
1155 c = C()
1156 self.assertTrue(c.inst is None)
1157
1158 def test_bad_default(self):
1159 class Foo:

Callers

nothing calls this directly

Calls 3

AClass · 0.70
BClass · 0.70
CClass · 0.70

Tested by

no test coverage detected