Kaydet (Commit) ab9d8d64 authored tarafından R. David Murray's avatar R. David Murray

Escape file path before searching for it in output via regex

üst 7d101293
...@@ -10,6 +10,7 @@ from test.support import captured_stderr ...@@ -10,6 +10,7 @@ from test.support import captured_stderr
import builtins import builtins
import os import os
import sys import sys
import re
import encodings import encodings
import subprocess import subprocess
import sysconfig import sysconfig
...@@ -108,7 +109,8 @@ class HelperFunctionsTests(unittest.TestCase): ...@@ -108,7 +109,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out: with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set()) site.addpackage(pth_dir, pth_fn, set())
self.assertRegex(err_out.getvalue(), "line 1") self.assertRegex(err_out.getvalue(), "line 1")
self.assertRegex(err_out.getvalue(), os.path.join(pth_dir, pth_fn)) self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: the previous two should be independent checks so that the # XXX: the previous two should be independent checks so that the
# order doesn't matter. The next three could be a single check # order doesn't matter. The next three could be a single check
# but my regex foo isn't good enough to write it. # but my regex foo isn't good enough to write it.
...@@ -122,7 +124,8 @@ class HelperFunctionsTests(unittest.TestCase): ...@@ -122,7 +124,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out: with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set()) site.addpackage(pth_dir, pth_fn, set())
self.assertRegex(err_out.getvalue(), "line 2") self.assertRegex(err_out.getvalue(), "line 2")
self.assertRegex(err_out.getvalue(), os.path.join(pth_dir, pth_fn)) self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment. # XXX: ditto previous XXX comment.
self.assertRegex(err_out.getvalue(), 'Traceback') self.assertRegex(err_out.getvalue(), 'Traceback')
self.assertRegex(err_out.getvalue(), 'ImportError') self.assertRegex(err_out.getvalue(), 'ImportError')
...@@ -133,7 +136,8 @@ class HelperFunctionsTests(unittest.TestCase): ...@@ -133,7 +136,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out: with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set()) site.addpackage(pth_dir, pth_fn, set())
self.assertRegex(err_out.getvalue(), "line 1") self.assertRegex(err_out.getvalue(), "line 1")
self.assertRegex(err_out.getvalue(), os.path.join(pth_dir, pth_fn)) self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment. # XXX: ditto previous XXX comment.
self.assertRegex(err_out.getvalue(), 'Traceback') self.assertRegex(err_out.getvalue(), 'Traceback')
self.assertRegex(err_out.getvalue(), 'TypeError') self.assertRegex(err_out.getvalue(), 'TypeError')
......
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