blob: 9b1eba5bb12b642376a12d44bc0fa1d02a489db0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
[ "$1" = python3-pypubsub ] || exit 0
python3 - << 'EOF'
from pubsub import pub
received = []
def on_message(msg):
received.append(msg)
pub.subscribe(on_message, "test.topic")
pub.sendMessage("test.topic", msg="hello")
assert received == ["hello"], f"Expected ['hello'], got {received}"
pub.unsubscribe(on_message, "test.topic")
pub.sendMessage("test.topic", msg="world")
assert received == ["hello"], "Unsubscribed listener should not receive messages"
print("python3-pypubsub OK")
EOF
|