MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_object_new

Method test_object_new

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

Source from the content-addressed store, hash-verified

1853 self.assertRaises(TypeError, C)
1854
1855 def test_object_new(self):
1856 class A(object):
1857 pass
1858 object.__new__(A)
1859 self.assertRaises(TypeError, object.__new__, A, 5)
1860 object.__init__(A())
1861 self.assertRaises(TypeError, object.__init__, A(), 5)
1862
1863 class A(object):
1864 def __init__(self, foo):
1865 self.foo = foo
1866 object.__new__(A)
1867 object.__new__(A, 5)
1868 object.__init__(A(3))
1869 self.assertRaises(TypeError, object.__init__, A(3), 5)
1870
1871 class A(object):
1872 def __new__(cls, foo):
1873 return object.__new__(cls)
1874 object.__new__(A)
1875 self.assertRaises(TypeError, object.__new__, A, 5)
1876 object.__init__(A(3))
1877 object.__init__(A(3), 5)
1878
1879 class A(object):
1880 def __new__(cls, foo):
1881 return object.__new__(cls)
1882 def __init__(self, foo):
1883 self.foo = foo
1884 object.__new__(A)
1885 self.assertRaises(TypeError, object.__new__, A, 5)
1886 object.__init__(A(3))
1887 self.assertRaises(TypeError, object.__init__, A(3), 5)
1888
1889 # TODO: RUSTPYTHON; The `expectedFailure` here is from CPython, so this test must fail
1890 # @unittest.expectedFailure

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