summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-17 05:05:44 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-17 05:05:44 (GMT)
commit96384b93aae1d1e45dda21c4024d7d083c91626d (patch)
tree0f1fc36742c65bdbd227faffea75068b580112fa /Lib/test/test_descr.py
parent80e22b56d3efdf2351307de6c6706ebed934fe7a (diff)
downloadcpython-96384b93aae1d1e45dda21c4024d7d083c91626d.zip
cpython-96384b93aae1d1e45dda21c4024d7d083c91626d.tar.gz
cpython-96384b93aae1d1e45dda21c4024d7d083c91626d.tar.bz2
make extra arguments to object.__init__/__new__ to errors in most cases (finishes #1683368)
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index bf82a88..5759eff 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4502,6 +4502,26 @@ order (MRO) for bases """
for o in gc.get_objects():
self.assertIsNot(type(o), X)
+ def test_object_new_and_init_with_parameters(self):
+ # See issue #1683368
+ class OverrideNeither:
+ pass
+ self.assertRaises(TypeError, OverrideNeither, 1)
+ self.assertRaises(TypeError, OverrideNeither, kw=1)
+ class OverrideNew:
+ def __new__(cls, foo, kw=0, *args, **kwds):
+ return object.__new__(cls, *args, **kwds)
+ class OverrideInit:
+ def __init__(self, foo, kw=0, *args, **kwargs):
+ return object.__init__(self, *args, **kwargs)
+ class OverrideBoth(OverrideNew, OverrideInit):
+ pass
+ for case in OverrideNew, OverrideInit, OverrideBoth:
+ case(1)
+ case(1, kw=2)
+ self.assertRaises(TypeError, case, 1, 2, 3)
+ self.assertRaises(TypeError, case, 1, 2, foo=3)
+
class DictProxyTests(unittest.TestCase):
def setUp(self):