summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_site.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-27 00:03:13 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-27 00:03:13 (GMT)
commitab9d8d64a71d3c431e99d6ccf0a3e696b24d4a6a (patch)
tree2b0d88f796676bfb6d6f8ec4dda4f7787853f07b /Lib/test/test_site.py
parent7d10129369d55821e51d28d4efebaee3ac79a85b (diff)
downloadcpython-ab9d8d64a71d3c431e99d6ccf0a3e696b24d4a6a.zip
cpython-ab9d8d64a71d3c431e99d6ccf0a3e696b24d4a6a.tar.gz
cpython-ab9d8d64a71d3c431e99d6ccf0a3e696b24d4a6a.tar.bz2
Escape file path before searching for it in output via regex
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r--Lib/test/test_site.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 0ed4706..fb41fc9 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -10,6 +10,7 @@ from test.support import captured_stderr
import builtins
import os
import sys
+import re
import encodings
import subprocess
import sysconfig
@@ -108,7 +109,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
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
# order doesn't matter. The next three could be a single check
# but my regex foo isn't good enough to write it.
@@ -122,7 +124,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
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.
self.assertRegex(err_out.getvalue(), 'Traceback')
self.assertRegex(err_out.getvalue(), 'ImportError')
@@ -133,7 +136,8 @@ class HelperFunctionsTests(unittest.TestCase):
with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
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.
self.assertRegex(err_out.getvalue(), 'Traceback')
self.assertRegex(err_out.getvalue(), 'TypeError')