You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/libs/waitress/tests/test_init.py

52 lines
1.2 KiB

5 years ago
import unittest
class Test_serve(unittest.TestCase):
def _callFUT(self, app, **kw):
from waitress import serve
return serve(app, **kw)
def test_it(self):
server = DummyServerFactory()
app = object()
result = self._callFUT(app, _server=server, _quiet=True)
self.assertEqual(server.app, app)
self.assertEqual(result, None)
self.assertEqual(server.ran, True)
class Test_serve_paste(unittest.TestCase):
def _callFUT(self, app, **kw):
from waitress import serve_paste
return serve_paste(app, None, **kw)
def test_it(self):
server = DummyServerFactory()
app = object()
result = self._callFUT(app, _server=server, _quiet=True)
self.assertEqual(server.app, app)
self.assertEqual(result, 0)
self.assertEqual(server.ran, True)
class DummyServerFactory(object):
ran = False
def __call__(self, app, **kw):
self.adj = DummyAdj(kw)
self.app = app
self.kw = kw
return self
def run(self):
self.ran = True
class DummyAdj(object):
verbose = False
def __init__(self, kw):
self.__dict__.update(kw)