GeezerVison is showing github.com — [GR-57290] Add regression test for clearing globals. · elide-dev/graalpython@8f70104
File tree
Expand file treeCollapse file tree
Open diff view settings
graalpython/com.oracle.graal.python.test/src/tests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: graalpython/com.oracle.graal.python.test/src/tests/test_frame_tests.py +11-1Lines changed: 11 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. |
| 1 | +# Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. |
2 | 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 | 3 | # |
4 | 4 | # The Universal Permissive License (UPL), Version 1.0 |
@@ -221,3 +221,13 @@ class Foo: |
221 | 221 | # assert e.__traceback__.tb_frame.f_back.f_code == sys._getframe(0).f_back.f_code |
222 | 222 | # assert e.__traceback__.tb_next.tb_next.tb_frame.f_back.f_code == foo.__code__ |
223 | 223 | # assert e.__traceback__.tb_next.tb_frame.f_back.f_code == test_backref_from_traceback.__code__ |
| 224 | + |
| 225 | + |
| 226 | +def test_clearing_globals(): |
| 227 | + global foo, junk |
| 228 | + foo = 123 |
| 229 | + assert "foo" in globals().keys() |
| 230 | + assert "junk" not in globals().keys() |
| 231 | + junk = globals().clear() |
| 232 | + assert "foo" not in globals().keys() |
| 233 | + assert "junk" in globals().keys() |