Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-74929: Implement PEP 667#115153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
gh-74929: Implement PEP 667#115153
Changes from1 commit
42d71867eeab1b60e70e71454ce40045274de73bc9ca92393ff886ff9690a2d6e9848ab84b0dfbebff28d846de9d00a7421a4344df720e1264d37722eadbf0cbae1999e7edf8523cb754b83311ae2db7cbf45c02026e15ef42980de693ad05dd045b30ecd4df35c5e35844fb406277f9e1c3f56b672d843e325728dc4664652f641f29e6a3e0ca4fef78156a4503145cdac22c49287ff378aacfFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import copy | ||
| import gc | ||
| import operator | ||
| import re | ||
| @@ -300,6 +301,77 @@ def test_as_dict(self): | ||
| self.assertEqual(len(d.items()), 4) | ||
| self.assertIn(('x', 1), d.items()) | ||
| self.assertEqual(d.__getitem__('x'), 1) | ||
| d.__setitem__('x', 2) | ||
| self.assertEqual(d['x'], 2) | ||
| self.assertEqual(d.get('x'), 2) | ||
| self.assertIs(d.get('non_exist', None), None) | ||
| self.assertEqual(d.__len__(), 4) | ||
| self.assertEqual(set([key for key in d]), set(['x', 'y', 'd', 'self'])) | ||
| self.assertIn('x', d) | ||
| self.assertTrue(d.__contains__('x')) | ||
gaogaotiantian marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| self.assertEqual(reversed(d), list(reversed(d.keys()))) | ||
| d.update({'x': 3, 'z': 4}) | ||
| self.assertEqual(d['x'], 3) | ||
| self.assertEqual(d['z'], 4) | ||
| with self.assertRaises(TypeError): | ||
| d.update([1, 2]) | ||
| self.assertEqual(d.setdefault('x', 5), 3) | ||
| self.assertEqual(d.setdefault('new', 5), 5) | ||
| self.assertEqual(d['new'], 5) | ||
| def test_as_number(self): | ||
| x = 1 | ||
| y = 2 | ||
| d = sys._getframe().f_locals | ||
| self.assertIn('z', d | {'z': 3}) | ||
| d |= {'z': 3} | ||
| self.assertEqual(d['z'], 3) | ||
| d |= {'y': 3} | ||
| self.assertEqual(d['y'], 3) | ||
| with self.assertRaises(TypeError): | ||
| d |= 3 | ||
| with self.assertRaises(TypeError): | ||
| _ = d | [3] | ||
| def test_repr(self): | ||
| x = 1 | ||
| # Introduce a reference cycle | ||
| frame = sys._getframe() | ||
| self.assertEqual(repr(frame.f_locals), repr(dict(frame.f_locals))) | ||
| def test_delete(self): | ||
| x = 1 | ||
| d = sys._getframe().f_locals | ||
| with self.assertRaises(TypeError): | ||
| del d['x'] | ||
| with self.assertRaises(TypeError): | ||
| d.clear() | ||
| with self.assertRaises(TypeError): | ||
| d.pop('x') | ||
| def test_unsupport(self): | ||
| x = 1 | ||
| d = sys._getframe().f_locals | ||
| with self.assertRaises(TypeError): | ||
| d.copy() | ||
| with self.assertRaises(TypeError): | ||
| copy.copy(d) | ||
| with self.assertRaises(TypeError): | ||
| copy.deepcopy(d) | ||
| with self.assertRaises(TypeError): | ||
| d.get(1) | ||
gaogaotiantian marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| with self.assertRaises(TypeError): | ||
| d.setdefault(1, 'x') | ||
| class TestIncompleteFrameAreInvisible(unittest.TestCase): | ||
Uh oh!
There was an error while loading.Please reload this page.