diff options
| author | Tim Graham <timograham@gmail.com> | 2016-09-16 12:15:00 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-17 15:44:06 -0400 |
| commit | 8119b679eb85cdc0ae3d321e54d06dd0200a1e82 (patch) | |
| tree | b4f4e40a371569a260a39ca310e8e984d8582d74 /tests | |
| parent | 17677d510f65012531a5af57fd056fb15cfe1067 (diff) | |
Refs #27025 -- Fixed "invalid escape sequence" warnings in Python 3.6.
http://bugs.python.org/issue27364
Diffstat (limited to 'tests')
23 files changed, 42 insertions, 42 deletions
diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py index f57a9c8117..6f6f8838f3 100644 --- a/tests/admin_docs/tests.py +++ b/tests/admin_docs/tests.py @@ -153,8 +153,8 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase): def test_simplify_regex(self): tests = ( ('^a', '/a'), - ('^(?P<a>\w+)/b/(?P<c>\w+)/$', '/<a>/b/<c>/'), - ('^(?P<a>\w+)/b/(?P<c>\w+)$', '/<a>/b/<c>'), + (r'^(?P<a>\w+)/b/(?P<c>\w+)/$', '/<a>/b/<c>/'), + (r'^(?P<a>\w+)/b/(?P<c>\w+)$', '/<a>/b/<c>'), ) for pattern, output in tests: self.assertEqual(simplify_regex(pattern), output) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 567a8f14f8..84b44931b3 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -717,7 +717,7 @@ class ManageNoSettings(AdminScriptTestCase): args = ['check', 'admin_scripts'] out, err = self.run_manage(args) self.assertNoOutput(out) - self.assertOutput(err, "No module named '?(test_project\.)?settings'?", regex=True) + self.assertOutput(err, r"No module named '?(test_project\.)?settings'?", regex=True) def test_builtin_with_bad_settings(self): "no settings: manage.py builtin commands fail if settings file (from argument) doesn't exist" @@ -950,7 +950,7 @@ class ManageAlternateSettings(AdminScriptTestCase): args = ['check', 'admin_scripts'] out, err = self.run_manage(args) self.assertNoOutput(out) - self.assertOutput(err, "No module named '?(test_project\.)?settings'?", regex=True) + self.assertOutput(err, r"No module named '?(test_project\.)?settings'?", regex=True) def test_builtin_with_settings(self): "alternate: manage.py builtin commands work with settings provided as argument" @@ -985,7 +985,7 @@ class ManageAlternateSettings(AdminScriptTestCase): args = ['noargs_command'] out, err = self.run_manage(args) self.assertNoOutput(out) - self.assertOutput(err, "No module named '?(test_project\.)?settings'?", regex=True) + self.assertOutput(err, r"No module named '?(test_project\.)?settings'?", regex=True) def test_custom_command_with_settings(self): "alternate: manage.py can execute user commands if settings are provided as argument" diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index fd8056513b..ef0e44029f 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -2289,7 +2289,7 @@ class AdminViewStringPrimaryKeyTest(TestCase): cls.p1 = PrePopulatedPost.objects.create(title='A Long Title', published=True, slug='a-long-title') cls.pk = ( "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 " - """-_.!~*'() ;/?:@&=+$, <>#%" {}|\^[]`""" + r"""-_.!~*'() ;/?:@&=+$, <>#%" {}|\^[]`""" ) cls.m1 = ModelWithStringPrimaryKey.objects.create(string_pk=cls.pk) content_type_pk = ContentType.objects.get_for_model(ModelWithStringPrimaryKey).pk @@ -4323,7 +4323,7 @@ class SeleniumTests(AdminSeleniumTestCase): self.selenium.find_element_by_id('id_relatedprepopulated_set-2-1-pubdate').send_keys('1981-08-22') self.get_select_option('#id_relatedprepopulated_set-2-1-status', 'option one').click() self.selenium.find_element_by_id('id_relatedprepopulated_set-2-1-name').send_keys( - 'a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters' + r'a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters' ) slug1 = self.selenium.find_element_by_id('id_relatedprepopulated_set-2-1-slug1').get_attribute('value') slug2 = self.selenium.find_element_by_id('id_relatedprepopulated_set-2-1-slug2').get_attribute('value') @@ -4365,7 +4365,7 @@ class SeleniumTests(AdminSeleniumTestCase): slug2='option-two-and-now-tabular-inline', ) RelatedPrepopulated.objects.get( - name='a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters', + name=r'a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters', pubdate='1981-08-22', status='option one', slug1='tabular-inline-ignored-characters-1981-08-22', diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index baf4b8adc6..057771bfa4 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -419,7 +419,7 @@ class AdminFileWidgetTests(TestDataMixin, TestCase): self.assertHTMLEqual( w.render('test', self.album.cover_art), '<p class="file-upload">Currently: <a href="%(STORAGE_URL)salbums/' - 'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> ' + r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> ' '<span class="clearable-file-input">' '<input type="checkbox" name="test-clear" id="test-clear_id" /> ' '<label for="test-clear_id">Clear</label></span><br />' @@ -441,7 +441,7 @@ class AdminFileWidgetTests(TestDataMixin, TestCase): self.assertContains( response, '<p><a href="%(STORAGE_URL)salbums/hybrid_theory.jpg">' - 'albums\hybrid_theory.jpg</a></p>' % {'STORAGE_URL': default_storage.url('')}, + r'albums\hybrid_theory.jpg</a></p>' % {'STORAGE_URL': default_storage.url('')}, html=True, ) self.assertNotContains( diff --git a/tests/auth_tests/test_models.py b/tests/auth_tests/test_models.py index 5f66a48141..a92f882de0 100644 --- a/tests/auth_tests/test_models.py +++ b/tests/auth_tests/test_models.py @@ -117,8 +117,8 @@ class UserManagerTestCase(TestCase): self.assertEqual(returned, 'normal@domain.com') def test_create_user_email_domain_normalize_with_whitespace(self): - returned = UserManager.normalize_email('email\ with_whitespace@D.COM') - self.assertEqual(returned, 'email\ with_whitespace@d.com') + returned = UserManager.normalize_email(r'email\ with_whitespace@D.COM') + self.assertEqual(returned, r'email\ with_whitespace@d.com') def test_empty_username(self): with self.assertRaisesMessage(ValueError, 'The given username must be set'): diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 033a5e8912..e46fdab8e3 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -552,7 +552,7 @@ class ExpressionsTests(TestCase): self.assertEqual(c_qs.get(), c) def test_patterns_escape(self): - """ + r""" Test that special characters (e.g. %, _ and \) stored in database are properly escaped when using a pattern lookup with an expression refs #16731 @@ -584,7 +584,7 @@ class ExpressionsTests(TestCase): ordered=False) def test_insensitive_patterns_escape(self): - """ + r""" Test that special characters (e.g. %, _ and \) stored in database are properly escaped when using a case insensitive pattern lookup with an expression -- refs #16731 diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py index 6f4b9fd2cd..1a6385dbf9 100644 --- a/tests/field_deconstruction/tests.py +++ b/tests/field_deconstruction/tests.py @@ -158,11 +158,11 @@ class FieldDeconstructionTests(SimpleTestCase): self.assertEqual(kwargs, {"upload_to": "foo/bar", "max_length": 200}) def test_file_path_field(self): - field = models.FilePathField(match=".*\.txt$") + field = models.FilePathField(match=r".*\.txt$") name, path, args, kwargs = field.deconstruct() self.assertEqual(path, "django.db.models.FilePathField") self.assertEqual(args, []) - self.assertEqual(kwargs, {"match": ".*\.txt$"}) + self.assertEqual(kwargs, {"match": r".*\.txt$"}) field = models.FilePathField(recursive=True, allow_folders=True, max_length=123) name, path, args, kwargs = field.deconstruct() self.assertEqual(path, "django.db.models.FilePathField") diff --git a/tests/forms_tests/field_tests/test_filepathfield.py b/tests/forms_tests/field_tests/test_filepathfield.py index e747189c3e..5c4bd1bbb2 100644 --- a/tests/forms_tests/field_tests/test_filepathfield.py +++ b/tests/forms_tests/field_tests/test_filepathfield.py @@ -53,7 +53,7 @@ class FilePathFieldTest(SimpleTestCase): def test_filepathfield_3(self): path = upath(forms.__file__) path = os.path.dirname(os.path.abspath(path)) + '/' - f = FilePathField(path=path, match='^.*?\.py$') + f = FilePathField(path=path, match=r'^.*?\.py$') f.choices.sort() expected = [ ('/django/forms/__init__.py', '__init__.py'), @@ -72,7 +72,7 @@ class FilePathFieldTest(SimpleTestCase): def test_filepathfield_4(self): path = os.path.abspath(upath(forms.__file__)) path = os.path.dirname(path) + '/' - f = FilePathField(path=path, recursive=True, match='^.*?\.py$') + f = FilePathField(path=path, recursive=True, match=r'^.*?\.py$') f.choices.sort() expected = [ ('/django/forms/__init__.py', '__init__.py'), diff --git a/tests/forms_tests/field_tests/test_regexfield.py b/tests/forms_tests/field_tests/test_regexfield.py index ece958e509..c0e75438f6 100644 --- a/tests/forms_tests/field_tests/test_regexfield.py +++ b/tests/forms_tests/field_tests/test_regexfield.py @@ -48,8 +48,8 @@ class RegexFieldTest(SimpleTestCase): f.clean('123') six.assertRaisesRegex( self, ValidationError, - "'Ensure this value has at least 5 characters \(it has 3\)\.'," - " u?'Enter a valid value\.'", + r"'Ensure this value has at least 5 characters \(it has 3\)\.'," + r" u?'Enter a valid value\.'", f.clean, 'abc' ) self.assertEqual('12345', f.clean('12345')) @@ -60,7 +60,7 @@ class RegexFieldTest(SimpleTestCase): f.clean('12345a') def test_regexfield_unicode_characters(self): - f = RegexField('^\w+$') + f = RegexField(r'^\w+$') self.assertEqual('éèøçÎÎ你好', f.clean('éèøçÎÎ你好')) def test_change_regex_after_init(self): diff --git a/tests/forms_tests/field_tests/test_splitdatetimefield.py b/tests/forms_tests/field_tests/test_splitdatetimefield.py index 1febb57b28..e46eb163a8 100644 --- a/tests/forms_tests/field_tests/test_splitdatetimefield.py +++ b/tests/forms_tests/field_tests/test_splitdatetimefield.py @@ -23,7 +23,7 @@ class SplitDateTimeFieldTest(SimpleTestCase): f.clean('') with self.assertRaisesMessage(ValidationError, "'Enter a list of values.'"): f.clean('hello') - with six.assertRaisesRegex(self, ValidationError, "'Enter a valid date\.', u?'Enter a valid time\.'"): + with six.assertRaisesRegex(self, ValidationError, r"'Enter a valid date\.', u?'Enter a valid time\.'"): f.clean(['hello', 'there']) with self.assertRaisesMessage(ValidationError, "'Enter a valid time.'"): f.clean(['2006-01-10', 'there']) @@ -43,7 +43,7 @@ class SplitDateTimeFieldTest(SimpleTestCase): self.assertIsNone(f.clean(['', ''])) with self.assertRaisesMessage(ValidationError, "'Enter a list of values.'"): f.clean('hello') - with six.assertRaisesRegex(self, ValidationError, "'Enter a valid date\.', u?'Enter a valid time\.'"): + with six.assertRaisesRegex(self, ValidationError, r"'Enter a valid date\.', u?'Enter a valid time\.'"): f.clean(['hello', 'there']) with self.assertRaisesMessage(ValidationError, "'Enter a valid time.'"): f.clean(['2006-01-10', 'there']) diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index f86ab2d43c..44034d310d 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2914,7 +2914,7 @@ Good luck picking a username that doesn't already exist.</p> self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) six.assertRaisesRegex( self, ValidationError, - "'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] + r"'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] ) with self.assertRaisesMessage(ValidationError, "'Enter a valid country code.'"): f.clean(['61', '287654321', '123', 'Home']) @@ -2930,7 +2930,7 @@ Good luck picking a username that doesn't already exist.</p> self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) six.assertRaisesRegex( self, ValidationError, - "'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] + r"'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] ) with self.assertRaisesMessage(ValidationError, "'Enter a valid country code.'"): f.clean(['61', '287654321', '123', 'Home']) diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py index 8a0aa09b00..8137aeaeb0 100644 --- a/tests/gis_tests/gdal_tests/test_raster.py +++ b/tests/gis_tests/gdal_tests/test_raster.py @@ -71,7 +71,7 @@ class GDALRasterTests(unittest.TestCase): def test_rs_name_repr(self): self.assertEqual(self.rs_path, self.rs.name) - six.assertRegex(self, repr(self.rs), "<Raster object at 0x\w+>") + six.assertRegex(self, repr(self.rs), r"<Raster object at 0x\w+>") def test_rs_driver(self): self.assertEqual(self.rs.driver.name, 'GTiff') diff --git a/tests/gis_tests/test_spatialrefsys.py b/tests/gis_tests/test_spatialrefsys.py index 652dab3130..93ff3f6263 100644 --- a/tests/gis_tests/test_spatialrefsys.py +++ b/tests/gis_tests/test_spatialrefsys.py @@ -19,7 +19,7 @@ test_srs = ({ # From proj's "cs2cs -le" and Wikipedia (semi-minor only) 'ellipsoid': (6378137.0, 6356752.3, 298.257223563), 'eprec': (1, 1, 9), - 'wkt': re.sub('[\s+]', '', """ + 'wkt': re.sub(r'[\s+]', '', """ GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index 5ea574530f..75b1d80b79 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -97,7 +97,7 @@ class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase): self.fail("The token '%s' could not be found in %s, please check the test config" % (token, path)) def assertLocationCommentPresent(self, po_filename, line_number, *comment_parts): - """ + r""" self.assertLocationCommentPresent('django.po', 42, 'dirA', 'dirB', 'foo.py') verifies that the django.po file has a gettext-style location comment of the form @@ -307,7 +307,7 @@ class BasicExtractorTests(ExtractorTests): self, str(ws[2].message), r"The translator-targeted comment 'Translators: ignored i18n " r"comment #4' \(file templates[/\\]comments.thtml, line 8\) " - "was ignored, because it wasn't the last item on the line\." + r"was ignored, because it wasn't the last item on the line\." ) # Now test .po file contents self.assertTrue(os.path.exists(self.PO_FILE)) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index b0f77cfe06..5a05d16082 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -747,7 +747,7 @@ class FormattingTests(SimpleTestCase): self.maxDiff = 3000 # Catalan locale with translation.override('ca', deactivate=True): - self.assertEqual('j \d\e F \d\e Y', get_format('DATE_FORMAT')) + self.assertEqual(r'j \d\e F \d\e Y', get_format('DATE_FORMAT')) self.assertEqual(1, get_format('FIRST_DAY_OF_WEEK')) self.assertEqual(',', get_format('DECIMAL_SEPARATOR')) self.assertEqual('10:15', time_format(self.t)) diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index 588e2a9efb..c1b4e9be51 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -411,7 +411,7 @@ class LookupTests(TestCase): Article.objects.create(headline='Article with \\ backslash', pub_date=datetime(2005, 11, 22)) self.assertQuerysetEqual( Article.objects.filter(headline__contains='\\'), - ['<Article: Article with \ backslash>'] + [r'<Article: Article with \ backslash>'] ) def test_exclude(self): diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py index 847b11c088..93651d74bc 100644 --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -686,7 +686,7 @@ class ExecutorUnitTests(TestCase): self.assertEqual(plan, [(a2_impl, True)]) def test_minimize_rollbacks_branchy(self): - """ + r""" Minimize rollbacks when target has multiple in-app children. a: 1 <---- 3 <--\ @@ -731,7 +731,7 @@ class ExecutorUnitTests(TestCase): self.assertEqual(plan, exp) def test_backwards_nothing_to_do(self): - """ + r""" If the current state satisfies the given target, do nothing. a: 1 <--- 2 diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py index 472ec5a3ed..ad7e04581c 100644 --- a/tests/migrations/test_graph.py +++ b/tests/migrations/test_graph.py @@ -68,7 +68,7 @@ class GraphTests(SimpleTestCase): ) def test_complex_graph(self): - """ + r""" Tests a complex dependency graph: app_a: 0001 <-- 0002 <--- 0003 <-- 0004 diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index e8f3b71ee8..b464209a98 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -427,7 +427,7 @@ class LoaderTests(TestCase): ]}) def test_loading_squashed_ref_squashed(self): "Tests loading a squashed migration with a new migration referencing it" - """ + r""" The sample migrations are structured like this: app_1 1 --> 2 ---------------------*--> 3 *--> 4 diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index 0de67eb1f9..1b64477a20 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -169,7 +169,7 @@ class CustomFF(models.Model): class FilePathModel(models.Model): - path = models.FilePathField(path=os.path.dirname(upath(__file__)), match=".*\.py$", blank=True) + path = models.FilePathField(path=os.path.dirname(upath(__file__)), match=r".*\.py$", blank=True) try: diff --git a/tests/template_tests/syntax_tests/test_if_equal.py b/tests/template_tests/syntax_tests/test_if_equal.py index db02b090c0..6124608b08 100644 --- a/tests/template_tests/syntax_tests/test_if_equal.py +++ b/tests/template_tests/syntax_tests/test_if_equal.py @@ -98,7 +98,7 @@ class IfEqualTagTests(SimpleTestCase): @setup({'ifequal-split09': r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}"}) def test_ifequal_split09(self): - output = self.engine.render_to_string('ifequal-split09', {'a': 'slash\man'}) + output = self.engine.render_to_string('ifequal-split09', {'a': r'slash\man'}) self.assertEqual(output, 'yes') @setup({'ifequal-split10': r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}"}) diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py index ef4cb90ac4..e90d5e397d 100644 --- a/tests/utils_tests/test_http.py +++ b/tests/utils_tests/test_http.py @@ -95,9 +95,9 @@ class TestUtilsHttp(unittest.TestCase): r'\/example.com', r'/\example.com', 'http:///example.com', - 'http:/\//example.com', - 'http:\/example.com', - 'http:/\example.com', + r'http:/\//example.com', + r'http:\/example.com', + r'http:/\example.com', 'javascript:alert("XSS")', '\njavascript:alert(x)', '\x08//example.com', diff --git a/tests/utils_tests/test_jslex.py b/tests/utils_tests/test_jslex.py index 8308d2830b..dbf0d41b77 100644 --- a/tests/utils_tests/test_jslex.py +++ b/tests/utils_tests/test_jslex.py @@ -67,7 +67,7 @@ class JsTokensTest(SimpleTestCase): (r"""/a[\]]b/""", [r"""regex /a[\]]b/"""]), (r"""/[\]/]/gi""", [r"""regex /[\]/]/gi"""]), (r"""/\[[^\]]+\]/gi""", [r"""regex /\[[^\]]+\]/gi"""]), - (""" + (r""" rexl.re = { NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/, UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/, @@ -86,7 +86,7 @@ class JsTokensTest(SimpleTestCase): "punct }", "punct ;" ]), - (""" + (r""" rexl.re = { NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/, UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/, |
