Skip to content

Commit

Permalink
Merge pull request #30 from trilitech/elric1@py-test-bug
Browse files Browse the repository at this point in the history
check_section_text.py: fix subtle bug...
  • Loading branch information
elric1 authored Sep 28, 2023
2 parents fe8d7a3 + 80305c7 commit 2b28dc6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/integration/check_section_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@
from dataclasses import dataclass
import time

TIMEOUT = int(os.environ.get('TIMEOUT', '100'))
TIMEOUT = int(os.environ.get('TIMEOUT', '5'))

@dataclass
class Screen:
title: str
text: list[str]

def __str__(self):
return f"title=\"{self.title}\" Text=\"{''.join(self.text)}\""

def matches(self, content: str, content_lines: int, device) -> bool:
for l in self.text:
l = device_alter_content(device, l)
content = content.lstrip('\n')
if not content.startswith(l):
if len(l) == 0 or not content.startswith(l):
return False
content = content.removeprefix(l)

Expand Down Expand Up @@ -86,8 +89,10 @@ def check_multi_screen(url, title, content, content_lines, device):
"""Assert that the screen contents across all screens with the given title match expected content."""
while True:
def check_screen(screen):
assert screen.title == title, f"expected section '{title}' but on '{screen.title}'"
assert screen.matches(content, content_lines, device), f"{screen} did not match {content}"
assert screen.title == title, \
f"expected section '{title}' but on '{screen.title}'"
assert screen.matches(content, content_lines, device), \
f"{screen} did not match {content[:10]}...{content[-10:]}"
return screen

on_screen = with_retry(url, check_screen)
Expand Down

0 comments on commit 2b28dc6

Please sign in to comment.