diff options
author | R David Murray <rdmurray@bitdance.com> | 2016-09-08 17:59:53 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2016-09-08 17:59:53 (GMT) |
commit | 44b548dda872c0d4f30afd6b44fd74b053a55ad8 (patch) | |
tree | b3c1ff8485bc279000f9db95491ebc69a4385876 /Lib/unittest/test | |
parent | 513d7478a136e7646075592da2593476299cc8be (diff) | |
download | cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.zip cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.gz cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.bz2 |
#27364: fix "incorrect" uses of escape character in the stdlib.
And most of the tools.
Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and
Martin Panter.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/test_assertions.py | 18 | ||||
-rw-r--r-- | Lib/unittest/test/test_loader.py | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py index e6e2bc2..1b0e833 100644 --- a/Lib/unittest/test/test_assertions.py +++ b/Lib/unittest/test/test_assertions.py @@ -240,7 +240,7 @@ class TestLongMessage(unittest.TestCase): # Error messages are multiline so not testing on full message # assertTupleEqual and assertListEqual delegate to this method self.assertMessages('assertSequenceEqual', ([], [None]), - ["\+ \[None\]$", "^oops$", r"\+ \[None\]$", + [r"\+ \[None\]$", "^oops$", r"\+ \[None\]$", r"\+ \[None\] : oops$"]) def testAssertSetEqual(self): @@ -250,21 +250,21 @@ class TestLongMessage(unittest.TestCase): def testAssertIn(self): self.assertMessages('assertIn', (None, []), - ['^None not found in \[\]$', "^oops$", - '^None not found in \[\]$', - '^None not found in \[\] : oops$']) + [r'^None not found in \[\]$', "^oops$", + r'^None not found in \[\]$', + r'^None not found in \[\] : oops$']) def testAssertNotIn(self): self.assertMessages('assertNotIn', (None, [None]), - ['^None unexpectedly found in \[None\]$', "^oops$", - '^None unexpectedly found in \[None\]$', - '^None unexpectedly found in \[None\] : oops$']) + [r'^None unexpectedly found in \[None\]$', "^oops$", + r'^None unexpectedly found in \[None\]$', + r'^None unexpectedly found in \[None\] : oops$']) def testAssertDictEqual(self): self.assertMessages('assertDictEqual', ({}, {'key': 'value'}), [r"\+ \{'key': 'value'\}$", "^oops$", - "\+ \{'key': 'value'\}$", - "\+ \{'key': 'value'\} : oops$"]) + r"\+ \{'key': 'value'\}$", + r"\+ \{'key': 'value'\} : oops$"]) def testAssertDictContainsSubset(self): with warnings.catch_warnings(): diff --git a/Lib/unittest/test/test_loader.py b/Lib/unittest/test/test_loader.py index 4b97882..b2f9c88 100644 --- a/Lib/unittest/test/test_loader.py +++ b/Lib/unittest/test/test_loader.py @@ -390,7 +390,7 @@ class Test_TestLoader(unittest.TestCase): suite = loader.loadTestsFromName('abc () //') error, test = self.check_deferred_error(loader, suite) expected = "Failed to import test module: abc () //" - expected_regex = "Failed to import test module: abc \(\) //" + expected_regex = r"Failed to import test module: abc \(\) //" self.assertIn( expected, error, 'missing error string in %r' % error) @@ -502,7 +502,7 @@ class Test_TestLoader(unittest.TestCase): suite = loader.loadTestsFromName('abc () //', unittest) error, test = self.check_deferred_error(loader, suite) expected = "module 'unittest' has no attribute 'abc () //'" - expected_regex = "module 'unittest' has no attribute 'abc \(\) //'" + expected_regex = r"module 'unittest' has no attribute 'abc \(\) //'" self.assertIn( expected, error, 'missing error string in %r' % error) @@ -809,7 +809,7 @@ class Test_TestLoader(unittest.TestCase): suite = loader.loadTestsFromNames(['abc () //']) error, test = self.check_deferred_error(loader, list(suite)[0]) expected = "Failed to import test module: abc () //" - expected_regex = "Failed to import test module: abc \(\) //" + expected_regex = r"Failed to import test module: abc \(\) //" self.assertIn( expected, error, 'missing error string in %r' % error) @@ -928,7 +928,7 @@ class Test_TestLoader(unittest.TestCase): suite = loader.loadTestsFromNames(['abc () //'], unittest) error, test = self.check_deferred_error(loader, list(suite)[0]) expected = "module 'unittest' has no attribute 'abc () //'" - expected_regex = "module 'unittest' has no attribute 'abc \(\) //'" + expected_regex = r"module 'unittest' has no attribute 'abc \(\) //'" self.assertIn( expected, error, 'missing error string in %r' % error) |