Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support python setup.py test

  • Loading branch information...
commit f10f59204fc8e6217d1e787e2a20a6c5a0a5b4ba 1 parent 0d3e9a5
@graingert authored
Showing with 41 additions and 29 deletions.
  1. +0 −29 serve_tests.py
  2. +1 −0  setup.py
  3. +40 −0 socketIO_client/tests.py
View
29 serve_tests.py
@@ -1,29 +0,0 @@
-'Launch this server in another terminal window before running tests'
-from socketio import socketio_manage
-from socketio.namespace import BaseNamespace
-from socketio.server import SocketIOServer
-
-
-class Namespace(BaseNamespace):
-
- def on_aaa(self, *args):
- self.socket.send_packet(dict(
- type='event',
- name='ddd',
- args=args,
- endpoint=self.ns_name))
-
-
-class Application(object):
-
- def __call__(self, environ, start_response):
- socketio_manage(environ, {
- '': Namespace,
- '/chat': Namespace,
- '/news': Namespace,
- })
-
-
-if __name__ == '__main__':
- socketIOServer = SocketIOServer(('0.0.0.0', 8000), Application())
- socketIOServer.serve_forever()
View
1  setup.py
@@ -26,6 +26,7 @@
'anyjson',
'websocket-client',
],
+ test_suite="nose.collector",
packages=find_packages(),
include_package_data=True,
zip_safe=True)
View
40 socketIO_client/tests.py
@@ -3,6 +3,46 @@
from unittest import TestCase
+from socketio import socketio_manage
+from socketio.namespace import BaseNamespace as SIOBaseNameSpace
+from socketio.server import SocketIOServer
+
+from multiprocessing import Process
+
+
+class SIONamespace(SIOBaseNameSpace):
+
+ def on_aaa(self, *args):
+ self.socket.send_packet(dict(
+ type='event',
+ name='ddd',
+ args=args,
+ endpoint=self.ns_name))
+
+
+class Application(object):
+
+ def __call__(self, environ, start_response):
+ socketio_manage(environ, {
+ '': SIONamespace,
+ '/chat': SIONamespace,
+ '/news': SIONamespace,
+ })
+
+
+socketIOServer = SocketIOServer(('0.0.0.0', 8000), Application())
+
+p = Process(target=socketIOServer.serve_forever)
+
+
+def setup_module(module):
+ p.start()
+
+
+def teardown_module(module):
+ p.terminate()
+
+
PAYLOAD = {'bbb': 'ccc'}
ON_RESPONSE_CALLED = False
Please sign in to comment.
Something went wrong with that request. Please try again.