Skip to content

Commit ca901b4

Browse files
Refactor tests
1 parent 4b3d8d0 commit ca901b4

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

tests/receiverIntegrationTest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ def setUp(self):
2222

2323
def test_receives_message(self):
2424
# Given
25-
group = GROUP.hello()
2625
context = Context()
27-
radio = context.socket(RADIO)
28-
radio.connect(group.url)
2926
messages = []
3027

31-
with DishReceiver(context) as receiver:
28+
with DishReceiver(context) as receiver, context.socket(RADIO) as radio:
29+
group = GROUP.hello()
30+
radio.connect(group.url)
3231
receiver.register(lambda message: messages.append(message))
3332
receiver.start(group)
3433

tests/senderIntegrationTest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ def setUp(self):
2424

2525
def test_sends_message(self):
2626
# Given
27-
group = GROUP.hello()
2827
context = Context()
29-
dish = context.socket(DISH)
30-
dish.bind(group.url)
31-
dish.join(group.name)
3228
messages = []
3329

34-
with RadioSender(context) as sender:
30+
with RadioSender(context) as sender, context.socket(DISH) as dish:
31+
group = GROUP.hello()
32+
dish.bind(group.url)
33+
dish.join(group.name)
3534
sender.start(group)
3635
Thread(target=lambda: messages.append(dish.recv_json())).start()
3736

0 commit comments

Comments
 (0)