mirror of
https://github.com/cs01/gdbgui
synced 2024-11-16 07:47:46 +01:00
move tests to top level
This commit is contained in:
parent
3e51ae5c1d
commit
27b281117e
5 changed files with 75 additions and 1 deletions
2
setup.py
2
setup.py
|
@ -38,7 +38,7 @@ class TestCommand (Command):
|
|||
def run(self):
|
||||
# import here so dependency error on Flask is not
|
||||
# raised
|
||||
from gdbgui.tests import test_app
|
||||
from tests import test_app
|
||||
sys.exit(test_app.main())
|
||||
|
||||
|
||||
|
|
0
tests/tests/__init__.py
Normal file
0
tests/tests/__init__.py
Normal file
74
tests/tests/test_app.py
Executable file
74
tests/tests/test_app.py
Executable file
|
@ -0,0 +1,74 @@
|
|||
"""
|
||||
Unit tests
|
||||
|
||||
Run from top level directory: ./tests/test_app.py
|
||||
|
||||
See more on testing Flask apps: http://flask.pocoo.org/docs/0.11/testing/
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from gdbgui import backend
|
||||
import sys
|
||||
from flask_socketio import send
|
||||
|
||||
|
||||
PYTHON3 = sys.version_info.major == 3
|
||||
|
||||
backend.setup_backend(testing=True)
|
||||
socketio = backend.socketio
|
||||
|
||||
|
||||
@socketio.on('connect')
|
||||
def on_connect():
|
||||
send('connected')
|
||||
|
||||
|
||||
class TestWebsockets(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_connect(self):
|
||||
client = socketio.test_client(backend.app)
|
||||
received = client.get_received()
|
||||
self.assertEqual(len(received), 1)
|
||||
self.assertEqual(received[0]['args'], 'connected')
|
||||
client.disconnect()
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Built-in to unittest.TestCase"""
|
||||
self.app = backend.app.test_client()
|
||||
|
||||
def tearDown(self):
|
||||
"""Built-in to unittest.TestCase"""
|
||||
pass
|
||||
|
||||
def test_load_main_page(self):
|
||||
response = self.app.get('/')
|
||||
assert response.status_code == 200
|
||||
data = response.data.decode() if PYTHON3 else response.data
|
||||
assert '<!DOCTYPE html>' in data
|
||||
|
||||
|
||||
def main():
|
||||
loader = unittest.TestLoader()
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
# commented out for now, seems to be a flask_socketio issue
|
||||
# https://github.com/miguelgrinberg/Flask-SocketIO/issues/405
|
||||
suite.addTests(loader.loadTestsFromTestCase(TestWebsockets))
|
||||
suite.addTests(loader.loadTestsFromTestCase(Test))
|
||||
|
||||
runner = unittest.TextTestRunner(verbosity=1)
|
||||
result = runner.run(suite)
|
||||
return len(result.errors) + len(result.failures)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue