summaryrefslogtreecommitdiffstats
path: root/lang/python/python-aiosignal/test.sh
blob: 3d368c823fd08322765b073872dcc093bad40c45 (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
#!/bin/sh

[ "$1" = python3-aiosignal ] || exit 0

python3 - << 'EOF'

from aiosignal import Signal

# Test Signal creation and basic list operations
sig = Signal(owner=object())
assert len(sig) == 0

callback = lambda: None
sig.append(callback)
assert len(sig) == 1
assert sig[0] is callback

# Test freeze
sig.freeze()
assert sig.frozen

# Test that frozen signal raises on modification
try:
    sig.append(lambda: None)
    assert False, "should have raised"
except RuntimeError:
    pass

EOF