Commit a97ed09e authored by Jason Madden's avatar Jason Madden

Fix local test failures under Python 3.4 having to do with test file encoding issue.

parent 4021f3e7
......@@ -122,7 +122,13 @@ def discover(tests=None, ignore=None):
default_options = {'timeout': TIMEOUT}
for filename in tests:
if 'TESTRUNNER' in open(filename).read():
with open(filename, 'rb') as f:
# Some of the test files (e.g., test__socket_dns) are
# UTF8 encoded. Depending on the environment, Python 3 may
# try to decode those as ASCII, which fails with UnicodeDecodeError.
# Thus, be sure to open and compare in binary mode.
contents = f.read()
if b'TESTRUNNER' in contents:
module = __import__(filename.rsplit('.', 1)[0])
for cmd, options in module.TESTRUNNER():
if remove_options(cmd)[-1] in ignore:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment