-
Notifications
You must be signed in to change notification settings - Fork 5
/
tests.py
37 lines (28 loc) · 919 Bytes
/
tests.py
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
# -*- coding: utf-8 -*-
import asyncio
import sys
from unittest import IsolatedAsyncioTestCase
from asyncblink import signal
class AsyncBlinkTest(IsolatedAsyncioTestCase):
def setUp(self):
super(AsyncBlinkTest, self).setUp()
self.signal = signal('test-signal')
def test_send(self):
self.RECV_CALLED = False
def receiver(sender):
self.RECV_CALLED = True
return 'recv!'
self.signal.connect(receiver)
self.signal.send('sender!')
self.assertTrue(self.RECV_CALLED)
async def test_send_async(self):
self.CORO_CALLED = False
async def receiver(sender):
async def fn():
return None
await fn()
self.CORO_CALLED = True
self.signal.connect(receiver)
r = self.signal.send('sender')
await r[0][1]
self.assertTrue(self.CORO_CALLED)