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

Method test_object_new

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

Source from the content-addressed store, hash-verified

1952 self.assertRaises(TypeError, C)
1953
1954 def test_object_new(self):
1955 class A(object):
1956 pass
1957 object.__new__(A)
1958 self.assertRaises(TypeError, object.__new__, A, 5)
1959 object.__init__(A())
1960 self.assertRaises(TypeError, object.__init__, A(), 5)
1961
1962 class A(object):
1963 def __init__(self, foo):
1964 self.foo = foo
1965 object.__new__(A)
1966 object.__new__(A, 5)
1967 object.__init__(A(3))
1968 self.assertRaises(TypeError, object.__init__, A(3), 5)
1969
1970 class A(object):
1971 def __new__(cls, foo):
1972 return object.__new__(cls)
1973 object.__new__(A)
1974 self.assertRaises(TypeError, object.__new__, A, 5)
1975 object.__init__(A(3))
1976 object.__init__(A(3), 5)
1977
1978 class A(object):
1979 def __new__(cls, foo):
1980 return object.__new__(cls)
1981 def __init__(self, foo):
1982 self.foo = foo
1983 object.__new__(A)
1984 self.assertRaises(TypeError, object.__new__, A, 5)
1985 object.__init__(A(3))
1986 self.assertRaises(TypeError, object.__init__, A(3), 5)
1987
1988 @unittest.expectedFailure
1989 def test_restored_object_new(self):

Callers

nothing calls this directly

Calls 4

AClass · 0.70
__new__Method · 0.45
assertRaisesMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected