support python setup.py test
This commit is contained in:
parent
0d3e9a56ee
commit
f10f59204f
3 changed files with 41 additions and 29 deletions
|
|
@ -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()
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -26,6 +26,7 @@ setup(
|
||||||
'anyjson',
|
'anyjson',
|
||||||
'websocket-client',
|
'websocket-client',
|
||||||
],
|
],
|
||||||
|
test_suite="nose.collector",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
zip_safe=True)
|
zip_safe=True)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,46 @@ from time import sleep
|
||||||
from unittest import TestCase
|
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'}
|
PAYLOAD = {'bbb': 'ccc'}
|
||||||
ON_RESPONSE_CALLED = False
|
ON_RESPONSE_CALLED = False
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue