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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
From 3722f5ece7e22ed67a84bfaae464853a146d2eb4 Mon Sep 17 00:00:00 2001
From: Stein Magnus Jodal <jodal@debian.org>
Date: Thu, 5 Nov 2015 15:46:08 +0100
Subject: Fix tests
Based on upstream commits:
- b5d47f7b3497f1b713a20fe6306b7d9afdd8c408
- b2a76a33960040d7d3d27c68bf17c12f169f81c7
fix unittest failing on 1 CPU machines
---
test/test_manager.py | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/test/test_manager.py b/test/test_manager.py
index 8c229b0..fceb77d 100644
--- a/test/test_manager.py
+++ b/test/test_manager.py
@@ -16,10 +16,10 @@ class WSManagerTest(unittest.TestCase):
ws.sock.fileno.return_value = 1
m.add(ws)
- m.poller.register.assert_call_once_with(ws)
+ m.poller.register.assert_called_once_with(1)
m.remove(ws)
- m.poller.unregister.assert_call_once_with(ws)
+ m.poller.unregister.assert_called_once_with(1)
@patch('ws4py.manager.SelectPoller')
def test_cannot_add_websocket_more_than_once(self, MockSelectPoller):
@@ -49,7 +49,7 @@ class WSManagerTest(unittest.TestCase):
self.assertEqual(len(m), 1)
m.remove(ws)
self.assertEqual(len(m), 0)
- m.poller.unregister.assert_call_once_with(ws)
+ m.poller.unregister.assert_called_once_with(1)
m.poller.reset_mock()
m.remove(ws)
@@ -62,6 +62,7 @@ class WSManagerTest(unittest.TestCase):
self.assertFalse(m.running)
m.start()
+ time.sleep(0.2)
self.assertTrue(m.running)
m.stop()
@@ -97,8 +98,9 @@ class WSManagerTest(unittest.TestCase):
m.add(ws)
m.start()
+ time.sleep(0.2)
- ws.terminate.assert_call_once_with()
+ ws.terminate.assert_called_once_with()
m.stop()
@@ -109,7 +111,7 @@ class WSManagerTest(unittest.TestCase):
ws = MagicMock()
m.add(ws)
m.close_all()
- ws.terminate.assert_call_once_with(1001, 'Server is shutting down')
+ ws.close.assert_called_once_with(code=1001, reason='Server is shutting down')
@patch('ws4py.manager.SelectPoller')
def test_broadcast(self, MockSelectPoller):
@@ -120,7 +122,7 @@ class WSManagerTest(unittest.TestCase):
m.add(ws)
m.broadcast(b'hello there')
- ws.send.assert_call_once_with(b'hello there')
+ ws.send.assert_called_once_with(b'hello there', False)
@patch('ws4py.manager.SelectPoller')
def test_broadcast_failure_must_not_break_caller(self, MockSelectPoller):
|