Skip to content

Commit a780388

Browse files
committed
Assert the scopes can mutate without interfering with one another
1 parent dfa9225 commit a780388

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/test_scope.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,25 @@ def test_all_slots_copied():
4444

4545

4646
def test_scope_flags_copy():
47-
# A scope exists and a flag is appended to it.
47+
# Assert forking creates a deepcopy of the flag buffer. The new
48+
# scope is free to mutate without consequence to the old scope. The
49+
# old scope is free to mutate without consequence to the new scope.
4850
old_scope = Scope()
4951
old_scope.flags.set("a", True)
5052

51-
# Scope is forked; flag buffer is copied and contains the data of
52-
# the parent. The flag is overwritten on the child. The parent
53-
# scope can continue mutating without interfering with the child.
5453
new_scope = old_scope.fork()
5554
new_scope.flags.set("a", False)
5655
old_scope.flags.set("b", True)
56+
new_scope.flags.set("c", True)
5757

58-
# New scope has the change. Old scope was not polluted by changes
59-
# to the new scope.
6058
assert old_scope.flags.get() == [
6159
{"flag": "a", "result": True},
6260
{"flag": "b", "result": True},
6361
]
64-
assert new_scope.flags.get() == [{"flag": "a", "result": False}]
62+
assert new_scope.flags.get() == [
63+
{"flag": "a", "result": False},
64+
{"flag": "c", "result": True},
65+
]
6566

6667

6768
def test_merging(sentry_init, capture_events):

0 commit comments

Comments
 (0)