Skip to content

Commit 796e57f

Browse files
Merge pull request #570 from Crozzers/fix-syntax-warnings
Fix syntax warnings in test suite
2 parents 646e6d2 + d01087e commit 796e57f

9 files changed

+20
-19
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [pull #519] Add support for custom extras
66
- [pull #519] Drop Python 3.5 support
77
- [pull #568] Add `prepend` arg to toc extra (#397)
8+
- [pull #570] Fix syntax warnings in test suite
89

910

1011
## python-markdown2 2.4.13

test/test_markdown2.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import difflib
1515
import doctest
1616
from json import loads as json_loads
17+
import warnings
1718

1819
sys.path.insert(0, join(dirname(dirname(abspath(__file__)))))
1920
try:
@@ -150,11 +151,14 @@ def generate_tests(cls):
150151
opts_path = splitext(text_path)[0] + ".opts"
151152
if exists(opts_path):
152153
try:
153-
opts = eval(open(opts_path, 'r').read())
154+
with warnings.catch_warnings(record=True) as caught_warnings:
155+
opts = eval(open(opts_path, 'r').read())
156+
for warning in caught_warnings:
157+
print("WARNING: loading %s generated warning: %s - lineno %d" % (opts_path, warning.message, warning.lineno), file=sys.stderr)
154158
except Exception:
155159
_, ex, _ = sys.exc_info()
156160
print("WARNING: couldn't load `%s' opts file: %s" \
157-
% (opts_path, ex))
161+
% (opts_path, ex), file=sys.stderr)
158162

159163
toc_html_path = splitext(text_path)[0] + ".toc_html"
160164
if not exists(toc_html_path):

test/testall.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def testall():
6868
# capture and re-print stderr while process is running
6969
line = proc.stderr.readline().decode().strip()
7070
print(line, file=sys.stderr)
71-
if 'WARNING:test:' in line:
71+
if 'WARNING:' in line:
7272
# if stderr contains a warning, save this for later
7373
all_warnings.append((python, ver_str, line))
7474

test/tm-cases/link_patterns.opts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
3-
(re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
4-
(re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
5-
(re.compile("PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))),
3+
(re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
4+
(re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
5+
(re.compile(r"PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))),
66
],
77
}
8-
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
33
(re.compile(r'mozilla\s+bug\s+(\d+)', re.I), r'http://bugzilla.mozilla.org/show_bug.cgi?id=\1'),
4-
(re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
4+
(re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
55
],
66
}
7-
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
3-
(re.compile("Blah\s+(\d+)", re.I), r"http://foo.com/blah_blah_blah/\1"),
3+
(re.compile(r"Blah\s+(\d+)", re.I), r"http://foo.com/blah_blah_blah/\1"),
44
(re.compile("#([1-9][0-9]*)"), r"http://localhost/issue/\1"),
55
],
66
}
7-
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
3-
(re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
4-
(re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
5-
(re.compile("PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))),
3+
(re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
4+
(re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"),
5+
(re.compile(r"PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))),
66
],
77
}
8-
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
3-
(re.compile("#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues/\1"),
4-
(re.compile("@(\w+)", re.I), r"https://github.com/\1"),
3+
(re.compile(r"#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues/\1"),
4+
(re.compile(r"@(\w+)", re.I), r"https://github.com/\1"),
55
(re.compile("([0-9a-f]{6,40})", re.I), r"https://github.com/pyfa-org/Pyfa/commit/\1")
66
]
77
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{"extras": ["link-patterns"],
22
"link_patterns": [
3-
(re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
3+
(re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes/\1/"),
44
],
5-
}
5+
}

0 commit comments

Comments
 (0)