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

Method test_restored_object_new

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

Source from the content-addressed store, hash-verified

1987
1988 @unittest.expectedFailure
1989 def test_restored_object_new(self):
1990 class A(object):
1991 def __new__(cls, *args, **kwargs):
1992 raise AssertionError
1993 self.assertRaises(AssertionError, A)
1994 class B(A):
1995 __new__ = object.__new__
1996 def __init__(self, foo):
1997 self.foo = foo
1998 with warnings.catch_warnings():
1999 warnings.simplefilter('error', DeprecationWarning)
2000 b = B(3)
2001 self.assertEqual(b.foo, 3)
2002 self.assertEqual(b.__class__, B)
2003 del B.__new__
2004 self.assertRaises(AssertionError, B)
2005 del A.__new__
2006 with warnings.catch_warnings():
2007 warnings.simplefilter('error', DeprecationWarning)
2008 b = B(3)
2009 self.assertEqual(b.foo, 3)
2010 self.assertEqual(b.__class__, B)
2011
2012 def test_altmro(self):
2013 # Testing mro() and overriding it...

Callers

nothing calls this directly

Calls 3

BClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected