Skip to content

Commit a8c0baf

Browse files
committed
Relax regex for Failed
1 parent f1629ec commit a8c0baf

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tests/test_submission.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,19 @@ def run_tests(page, competition, submission, expected_result="Finished") -> None
3939
expect(page.locator(".ui.indicating")).to_be_visible()
4040
expect(page.locator(".ui.indicating")).not_to_be_visible()
4141
# Wait for the run to be completed (Finished or Failed) to show.
42-
finished_or_failed = re.compile(r"^(Finished|Failed)$")
42+
# "Failed" regex is more flexible because the cell also contain a question mark
43+
finished_or_failed = re.compile(r"^(Finished|Failed.*)$")
4344
try:
4445
expect(page.get_by_role("cell", name=finished_or_failed)).to_be_visible(timeout=25000)
4546
# If it does not, catch the error and reload the page in case the page didn't update automatically
4647
except:
4748
page.reload()
4849
expect(page.get_by_role("cell", name=finished_or_failed)).to_be_visible(timeout=2000)
4950
# Then we actually check if we got the expected result
50-
expect(page.get_by_role("cell", name=expected_result)).to_be_visible()
51-
if expected_result == "Finished":
51+
if expected_result == "Failed":
52+
expect(page.get_by_role("cell", name=re.compile(r"^Failed.*$"))).to_be_visible()
53+
elif expected_result == "Finished":
54+
expect(page.get_by_role("cell", name=expected_result)).to_be_visible()
5255
# Add to leaderboard and see if shows
5356
text = page.locator(".submission_row").first.inner_text()
5457
submission_Id = text.split(None, 1)
@@ -63,6 +66,11 @@ def run_tests(page, competition, submission, expected_result="Finished") -> None
6366
)
6467
).to_be_visible()
6568
expect(page.get_by_role("cell", name=submission_Id[0], exact=True)).to_be_visible()
69+
else:
70+
raise ValueError(
71+
f"Unsupported expected_result={expected_result!r}. "
72+
"Expected 'Finished' or 'Failed'."
73+
)
6674

6775

6876
def test_v2_code(page: Page):

0 commit comments

Comments
 (0)