Skip to content

Commit

Permalink
Make test warnings more visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Crozzers committed Feb 17, 2024
1 parent 749ee72 commit 08b1b37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions test/test_markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import difflib
import doctest
from json import loads as json_loads
import warnings

sys.path.insert(0, join(dirname(dirname(abspath(__file__)))))
try:
Expand Down Expand Up @@ -150,11 +151,14 @@ def generate_tests(cls):
opts_path = splitext(text_path)[0] + ".opts"
if exists(opts_path):
try:
opts = eval(open(opts_path, 'r').read())
with warnings.catch_warnings(record=True) as caught_warnings:
opts = eval(open(opts_path, 'r').read())
for warning in caught_warnings:
print("WARNING: loading %s generated warning: %s - lineno %d" % (opts_path, warning.message, warning.lineno), file=sys.stderr)
except Exception:
_, ex, _ = sys.exc_info()
print("WARNING: couldn't load `%s' opts file: %s" \
% (opts_path, ex))
% (opts_path, ex), file=sys.stderr)

toc_html_path = splitext(text_path)[0] + ".toc_html"
if not exists(toc_html_path):
Expand Down
2 changes: 1 addition & 1 deletion test/testall.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def testall():
# capture and re-print stderr while process is running
line = proc.stderr.readline().decode().strip()
print(line, file=sys.stderr)
if 'WARNING:test:' in line:
if 'WARNING:' in line:
# if stderr contains a warning, save this for later
all_warnings.append((python, ver_str, line))

Expand Down

0 comments on commit 08b1b37

Please sign in to comment.