Skip to content

Commit

Permalink
tests: Fix tests/check_acl_log.py outputs.
Browse files Browse the repository at this point in the history
This commit also fixes some output issues due to truncated lines
within f-strings or acl log lines that include trailing whitespace
in check_acl_log.py.  It also implicitly fixes the flake8 reported
issue:
  tests/check_acl_log.py:94:80: E501 line too long (80 > 79 characters)

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
dceara authored and putnopvut committed Sep 16, 2022
1 parent 7341c10 commit bc0ceed
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/check_acl_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def parse_acl_log(line):

def get_acl_log(entry_num=1):
with open("ovn-controller.log", "r") as controller_log:
acl_logs = [line for line in controller_log if "acl_log" in line]
acl_logs = [line.rstrip() for line in controller_log
if "acl_log" in line]
try:
return acl_logs[entry_num - 1]
except IndexError:
print(
f"There were not {entry_num} acl_log entries, \
only {len(acl_logs)}"
f"There were not {entry_num} acl_log entries, "
f"only {len(acl_logs)}"
)
exit(1)

Expand Down Expand Up @@ -91,14 +92,15 @@ def main():
try:
if parsed_log[key] != val:
print(
f"Expected log {key}={val} but got {key}={parsed_log[key]} \
in:\n\t'{acl_log}"
f"Expected log {key}={val} but got "
f"{key}={parsed_log[key]} "
f"in:\n\t'{acl_log}'"
)
exit(1)
except KeyError:
print(
f"Expected log {key}={val} but {key} does not exist \
in:\n\t'{acl_log}'"
f"Expected log {key}={val} but {key} does not exist in:\n"
f"\t'{acl_log}'"
)
exit(1)

Expand Down

0 comments on commit bc0ceed

Please sign in to comment.