MCPcopy Index your code
hub / github.com/python/cpython / test_basics

Method test_basics

Lib/test/test_typing.py:8164–8178  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8162 cool: int
8163
8164 def test_basics(self):
8165 Emp = NamedTuple('Emp', [('name', str), ('id', int)])
8166 self.assertIsSubclass(Emp, tuple)
8167 joe = Emp('Joe', 42)
8168 jim = Emp(name='Jim', id=1)
8169 self.assertIsInstance(joe, Emp)
8170 self.assertIsInstance(joe, tuple)
8171 self.assertEqual(joe.name, 'Joe')
8172 self.assertEqual(joe.id, 42)
8173 self.assertEqual(jim.name, 'Jim')
8174 self.assertEqual(jim.id, 1)
8175 self.assertEqual(Emp.__name__, 'Emp')
8176 self.assertEqual(Emp._fields, ('name', 'id'))
8177 self.assertEqual(Emp.__annotations__,
8178 collections.OrderedDict([('name', str), ('id', int)]))
8179
8180 def test_annotation_usage(self):
8181 tim = CoolEmployee('Tim', 9000)

Callers

nothing calls this directly

Calls 4

NamedTupleFunction · 0.90
assertIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected