Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
takos22 committed Apr 27, 2021
1 parent a0b53ee commit c011118
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,22 @@ def test_app_run():
async def set_running():
running.set()

app_thread = threading.Thread(
target=app.run,
kwargs=dict(
host="127.0.0.1",
port=8000,
debug=True,
limit_max_requests=1, # end after one request
callback_notify=set_running,
timeout_notify=1, # set the running event every second
),
)
def do_request():
if not running.wait(10.0):
raise TimeoutError("App hasn't started after 10s")

requests.get("http://127.0.0.1:8000")

app_thread.start()
if not running.wait(10.0):
raise TimeoutError("App hasn't started after 10s")
request_thread = threading.Thread(target=do_request)
request_thread.start()

requests.get("http://127.0.0.1:8000")
app.run(
host="127.0.0.1",
port=8000,
debug=True,
limit_max_requests=1, # end after one request
callback_notify=set_running,
timeout_notify=1, # set the running event every second
)

app_thread.join(10.0)
if app_thread.is_alive():
raise TimeoutError("App hasn't stoped after 10s")
request_thread.join()

0 comments on commit c011118

Please sign in to comment.