I am trying to emulate a http server on localhost for faster testing.
ex:
import my_module
class RequestsTestCase(unittest.TestCase):
def setUp(self):
# ...
html = 'hello, world'
my_server = MyServer(html, 8888)
my_server.run()
...
def test_my_module_request_phrase(self):
response = my_module.get_phrase('http://localhost:8888/')
self.assertEqual(response, 'hello, world')
Is something like this possible using python 3?
my_server.run()does. If it blocks, thensetUp()will not return, and your test(s) won't be executed.unittest.setUpbefore testing it?