blob: 3ffe0cdb3d4864097a0a65fa6d2054d27a0ef386 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
from __future__ import absolute_import
from raven.utils.transaction import TransactionStack
def test_simple():
stack = TransactionStack()
stack.push('foo')
assert len(stack) == 1
assert stack.peek() == 'foo'
bar = stack.push(['bar'])
assert len(stack) == 2
assert stack.peek() == ['bar']
stack.push({'baz': True})
assert len(stack) == 3
assert stack.peek() == {'baz': True}
stack.pop(bar)
assert len(stack) == 1
assert stack.peek() == 'foo'
stack.pop()
assert len(stack) == 0
assert stack.peek() == None
def test_context_manager():
stack = TransactionStack()
with stack('foo'):
assert stack.peek() == 'foo'
assert stack.peek() is None
|