Skip to content

Commit

Permalink
Add checking of results text against embedded failure info.
Browse files Browse the repository at this point in the history
Implementation is a bit ad-hoc

Fixes #49
  • Loading branch information
xmo-odoo authored and peterjc committed Dec 9, 2021
1 parent e3dee19 commit ccde8e2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test suite."""
import ast
import glob
import os.path
from os.path import join
Expand Down Expand Up @@ -61,6 +62,20 @@ def test_expected_failures(modpath, expected_failure):
needle = ": %s " % code
assert needle in out

with open(os.path.join(modpath, expected_failure)) as f:
doc = ast.get_docstring(
ast.parse(f.read(), expected_failure),
clean=True,
)

# keep "literal" lines, skip shell lines
result_check = "".join(
line + "\n" for line in doc.splitlines() if line.startswith(" RST")
)
if result_check:
modpath = os.path.join(modpath, "")
assert out.replace(modpath, " ") == result_check


def test_expected_successes(modpath):
"""Verify the positive test cases (expected successes)."""
Expand Down

0 comments on commit ccde8e2

Please sign in to comment.