Clean up test_dashboard
@@ -73,7 +73,7 @@ def test_dashboard(loop):
else:
raise Exception("dashboard not found")
- with Client("127.0.0.1:%d" % Scheduler.default_port, loop=loop) as c:
+ with Client(f"127.0.0.1:{Scheduler.default_port}", loop=loop):
pass
names = ["localhost", "127.0.0.1", get_ip()]
@@ -85,17 +85,20 @@ def test_dashboard(loop):
try:
# All addresses should respond
for name in names:
- uri = "http://%s:%d/status/" % (name, dashboard_port)
+ uri = f"http://{name}:{dashboard_port}/status/"
response = requests.get(uri)
- assert response.ok
+ response.raise_for_status()
break
- except Exception as f:
- print("got error on %r: %s" % (uri, f))
+ except Exception as e:
+ print(f"Got error on {uri!r}: {e.__class__.__name__}: {e}")
+ elapsed = time() - start
+ if elapsed > 10:
+ print(f"Timed out after {elapsed:.2f} seconds")
+ raise
sleep(0.1)
- assert time() < start + 10
with pytest.raises(Exception):
- requests.get("http://127.0.0.1:%d/status/" % dashboard_port)
+ requests.get(f"http://127.0.0.1:{dashboard_port}/status/")
def test_dashboard_non_standard_ports(loop):
