summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-05-10 22:53:10 (GMT)
committerGitHub <noreply@github.com>2024-05-10 22:53:10 (GMT)
commit35c436186b849f8f2f9fb866c59015c9d034d448 (patch)
tree7546150928886fe4527122625682ecc69dd10835 /Lib
parentb88889e9ffd7b2d2bdac75aecbf14e37fd68e337 (diff)
downloadcpython-35c436186b849f8f2f9fb866c59015c9d034d448.zip
cpython-35c436186b849f8f2f9fb866c59015c9d034d448.tar.gz
cpython-35c436186b849f8f2f9fb866c59015c9d034d448.tar.bz2
gh-118921: Add `copy()` method for `FrameLocalsProxy` (#118923)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_frame.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py
index 2122553..aee8d37 100644
--- a/Lib/test/test_frame.py
+++ b/Lib/test/test_frame.py
@@ -371,6 +371,15 @@ class TestFrameLocals(unittest.TestCase):
f_locals['o'] = f_locals['k']
self.assertEqual(o, 'a.b.c')
+ def test_copy(self):
+ x = 0
+ d = sys._getframe().f_locals
+ d_copy = d.copy()
+ self.assertIsInstance(d_copy, dict)
+ self.assertEqual(d_copy['x'], 0)
+ d_copy['x'] = 1
+ self.assertEqual(x, 0)
+
def test_update_with_self(self):
def f():
f_locals = sys._getframe().f_locals
@@ -405,9 +414,6 @@ class TestFrameLocals(unittest.TestCase):
def test_unsupport(self):
x = 1
d = sys._getframe().f_locals
- with self.assertRaises(AttributeError):
- d.copy()
-
with self.assertRaises(TypeError):
copy.copy(d)