re.escape os.sep so that \ is interpreted properly in the regex.

This commit is contained in:
Gregory P. Smith 2012-02-13 16:38:37 -08:00
parent 93b98ca445
commit 9903c705b8
1 changed files with 3 additions and 2 deletions

View File

@ -94,10 +94,11 @@ class TestMain(unittest.TestCase):
self.assertIn("Writing converted %s to %s" % ( self.assertIn("Writing converted %s to %s" % (
os.path.join(self.py2_src_dir, name), os.path.join(self.py2_src_dir, name),
os.path.join(self.py3_dest_dir, name+suffix)), stderr) os.path.join(self.py3_dest_dir, name+suffix)), stderr)
sep = re.escape(os.sep)
self.assertRegex( self.assertRegex(
stderr, r"No changes to .*/__init__\.py".replace("/", os.sep)) stderr, r"No changes to .*/__init__\.py".replace("/", sep))
self.assertNotRegex( self.assertNotRegex(
stderr, r"No changes to .*/trivial\.py".replace("/", os.sep)) stderr, r"No changes to .*/trivial\.py".replace("/", sep))
def test_filename_changing_on_output_two_files(self): def test_filename_changing_on_output_two_files(self):
"""2to3 two files in one directory with a new output dir.""" """2to3 two files in one directory with a new output dir."""