I am trying to setting up an acceptance test harness for a flask app and I am currently struggling to wait for the app to start before making calls.
Following construct works fine:
class SpinUpTests(unittest.TestCase):
def tearDown(self):
super().tearDown()
self.stubby_server.kill()
self.stubby_server.communicate()
def test_given_not_yet_running_when_created_without_config_then_started_on_default_port(self):
self.not_yet_running(5000)
self.stubby_server = subprocess.Popen(['python', '../../app/StubbyServer.py'], stdout=subprocess.PIPE)
time.sleep(1)#<--- I would like to get rid of this
self.then_started_on_port(5000)
I would like to wait on stdout for:
self.stubby_server = subprocess.Popen(['python', '../../app/StubbyServer.py'], stdout=subprocess.PIPE) time.sleep(1)#<--- I would like to get rid of this
- Running on http://127.0.0.1:[port]/ (Press CTRL+C to quit)
I tried
for line in self.stubby_server.stdout.readline()
but readline()
never finishes, tho I already see the output in the test output window.
Any ideas how I can wait for the flask app to start without having to use an explicit sleep()
?