diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2016-07-30 06:26:03 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2016-07-30 06:26:03 (GMT) |
commit | d78448e912126410117723c7d240bbdfff06df16 (patch) | |
tree | 73490ec91133beb78ecacda68510e3552b80e3b1 /Lib/test/test_builtin.py | |
parent | f6daa690e4ee8581e0e5aa87764c0562a16c9330 (diff) | |
download | cpython-d78448e912126410117723c7d240bbdfff06df16.zip cpython-d78448e912126410117723c7d240bbdfff06df16.tar.gz cpython-d78448e912126410117723c7d240bbdfff06df16.tar.bz2 |
Issue #27366: Implement PEP 487
- __init_subclass__ called when new subclasses defined
- __set_name__ called when descriptors are part of a
class definition
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 8cc1b00..acc4f9c 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1699,21 +1699,11 @@ class TestType(unittest.TestCase): self.assertEqual(x.spam(), 'spam42') self.assertEqual(x.to_bytes(2, 'little'), b'\x2a\x00') - def test_type_new_keywords(self): - class B: - def ham(self): - return 'ham%d' % self - C = type.__new__(type, - name='C', - bases=(B, int), - dict={'spam': lambda self: 'spam%s' % self}) - self.assertEqual(C.__name__, 'C') - self.assertEqual(C.__qualname__, 'C') - self.assertEqual(C.__module__, __name__) - self.assertEqual(C.__bases__, (B, int)) - self.assertIs(C.__base__, int) - self.assertIn('spam', C.__dict__) - self.assertNotIn('ham', C.__dict__) + def test_type_nokwargs(self): + with self.assertRaises(TypeError): + type('a', (), {}, x=5) + with self.assertRaises(TypeError): + type('a', (), dict={}) def test_type_name(self): for name in 'A', '\xc4', '\U0001f40d', 'B.A', '42', '': |