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

Method test_newslots

Lib/test/test_descr.py:1923–1939  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1921 self.assertNotHasAttr(a, 'x')
1922
1923 def test_newslots(self):
1924 # Testing __new__ slot override...
1925 class C(list):
1926 def __new__(cls):
1927 self = list.__new__(cls)
1928 self.foo = 1
1929 return self
1930 def __init__(self):
1931 self.foo = self.foo + 2
1932 a = C()
1933 self.assertEqual(a.foo, 3)
1934 self.assertEqual(a.__class__, C)
1935 class D(C):
1936 pass
1937 b = D()
1938 self.assertEqual(b.foo, 3)
1939 self.assertEqual(b.__class__, D)
1940
1941 @unittest.expectedFailure
1942 def test_bad_new(self):

Callers

nothing calls this directly

Calls 3

CClass · 0.70
DClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected