diff options
| author | Tim Graham <timograham@gmail.com> | 2016-12-07 17:42:31 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-07 17:42:31 -0500 |
| commit | b5f0b3478dfcf0335f8ac2038d59f54b4a05f2a0 (patch) | |
| tree | f3eb61bfdcf45c7b27fe3c480e9a7533746d1aad /tests/forms_tests | |
| parent | f909fa84bedb51778a175aadfe4cfe7a91fe06cd (diff) | |
Fixed #27579 -- Added aliases for Python 3's assertion names in SimpleTestCase.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/field_tests/test_regexfield.py | 9 | ||||
| -rw-r--r-- | tests/forms_tests/field_tests/test_splitdatetimefield.py | 5 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 15 |
3 files changed, 12 insertions, 17 deletions
diff --git a/tests/forms_tests/field_tests/test_regexfield.py b/tests/forms_tests/field_tests/test_regexfield.py index c0e75438f6..02a627b8d2 100644 --- a/tests/forms_tests/field_tests/test_regexfield.py +++ b/tests/forms_tests/field_tests/test_regexfield.py @@ -5,7 +5,6 @@ import re from django.forms import RegexField, ValidationError from django.test import SimpleTestCase -from django.utils import six class RegexFieldTest(SimpleTestCase): @@ -46,12 +45,12 @@ class RegexFieldTest(SimpleTestCase): f = RegexField('^[0-9]+$', min_length=5, max_length=10) with self.assertRaisesMessage(ValidationError, "'Ensure this value has at least 5 characters (it has 3).'"): f.clean('123') - six.assertRaisesRegex( - self, ValidationError, + with self.assertRaisesRegex( + ValidationError, r"'Ensure this value has at least 5 characters \(it has 3\)\.'," r" u?'Enter a valid value\.'", - f.clean, 'abc' - ) + ): + f.clean('abc') self.assertEqual('12345', f.clean('12345')) self.assertEqual('1234567890', f.clean('1234567890')) with self.assertRaisesMessage(ValidationError, "'Ensure this value has at most 10 characters (it has 11).'"): diff --git a/tests/forms_tests/field_tests/test_splitdatetimefield.py b/tests/forms_tests/field_tests/test_splitdatetimefield.py index e46eb163a8..db8df41441 100644 --- a/tests/forms_tests/field_tests/test_splitdatetimefield.py +++ b/tests/forms_tests/field_tests/test_splitdatetimefield.py @@ -5,7 +5,6 @@ import datetime from django.forms import SplitDateTimeField, ValidationError from django.forms.widgets import SplitDateTimeWidget from django.test import SimpleTestCase -from django.utils import six class SplitDateTimeFieldTest(SimpleTestCase): @@ -23,7 +22,7 @@ class SplitDateTimeFieldTest(SimpleTestCase): f.clean('') with self.assertRaisesMessage(ValidationError, "'Enter a list of values.'"): f.clean('hello') - with six.assertRaisesRegex(self, ValidationError, r"'Enter a valid date\.', u?'Enter a valid time\.'"): + with self.assertRaisesRegex(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 +42,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, r"'Enter a valid date\.', u?'Enter a valid time\.'"): + with self.assertRaisesRegex(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 8007ad85af..8e94d29463 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -22,7 +22,6 @@ from django.http import QueryDict from django.template import Context, Template from django.test import SimpleTestCase from django.test.utils import str_prefix -from django.utils import six from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import format_html @@ -1101,7 +1100,7 @@ value="Should escape < & > and <script>alert('xss')</ self.assertEqual(f.errors['password1'], ['Forbidden value 2.']) self.assertEqual(f.errors['password2'], ['Forbidden value 2.']) - with six.assertRaisesRegex(self, ValueError, "has no field named"): + with self.assertRaisesMessage(ValueError, "has no field named"): f.add_error('missing_field', 'Some error.') def test_update_error_dict(self): @@ -2442,7 +2441,7 @@ Password: <input type="password" name="password" required /> form = UserRegistration(auto_id=False) if form.is_valid(): - return 'VALID: %r' % sorted(six.iteritems(form.cleaned_data)) + return 'VALID: %r' % sorted(form.cleaned_data.items()) t = Template( '<form action="" method="post">\n' @@ -2912,8 +2911,8 @@ Good luck picking a username that doesn't already exist.</p> with self.assertRaisesMessage(ValidationError, "'Enter a complete value.'"): f.clean(['+61']) self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) - six.assertRaisesRegex( - self, ValidationError, + self.assertRaisesRegex( + ValidationError, r"'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] ) with self.assertRaisesMessage(ValidationError, "'Enter a valid country code.'"): @@ -2928,10 +2927,8 @@ Good luck picking a username that doesn't already exist.</p> with self.assertRaisesMessage(ValidationError, "'Enter a complete value.'"): f.clean(['+61']) self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) - six.assertRaisesRegex( - self, ValidationError, - r"'Enter a complete value\.', u?'Enter an extension\.'", f.clean, ['', '', '', 'Home'] - ) + with self.assertRaisesRegex(ValidationError, 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']) |
