summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-12-29 16:27:49 +0100
committerClaude Paroz <claude@2xlibre.net>2017-01-18 20:18:46 +0100
commit7b2f2e74adb36a4334e83130f6abc2f79d395235 (patch)
tree313387ba6a6f1311b43cf5fb4f2576d2d6c4f805 /tests/model_forms
parentf6acd1d271122d66de8061e75ae26137ddf02658 (diff)
downloaddjango-7b2f2e74adb36a4334e83130f6abc2f79d395235.tar.gz
Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/models.py3
-rw-r--r--tests/model_forms/tests.py34
2 files changed, 18 insertions, 19 deletions
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
index 333a6050ab..0914fc2587 100644
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -15,7 +15,6 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
-from django.utils import six
from django.utils._os import upath
from django.utils.six.moves import range
@@ -319,7 +318,7 @@ class BigInt(models.Model):
biggie = models.BigIntegerField()
def __str__(self):
- return six.text_type(self.biggie)
+ return str(self.biggie)
class MarkupField(models.CharField):
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 0fc516b55c..27143e97f4 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1162,7 +1162,7 @@ class ModelFormBasicTests(TestCase):
# inserted as 'initial' data in each Field.
f = RoykoForm(auto_id=False, instance=self.w_royko)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Name:</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" required /><br />
<span class="helptext">Use both first and last names.</span></td></tr>'''
)
@@ -1204,7 +1204,7 @@ class ModelFormBasicTests(TestCase):
'headline': 'Test headline',
'slug': 'test-headline',
'pub_date': '1984-02-06',
- 'writer': six.text_type(self.w_royko.pk),
+ 'writer': str(self.w_royko.pk),
'article': 'Hello.'
}, instance=art)
self.assertEqual(f.errors, {})
@@ -1294,7 +1294,7 @@ class ModelFormBasicTests(TestCase):
# fields with the 'choices' attribute are represented by a ChoiceField.
f = ArticleForm(auto_id=False)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr>
<tr><th>Slug:</th><td><input type="text" name="slug" maxlength="50" required /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>
@@ -1360,7 +1360,7 @@ class ModelFormBasicTests(TestCase):
f = PartialArticleForm(auto_id=False)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>''')
@@ -1398,9 +1398,9 @@ class ModelFormBasicTests(TestCase):
'headline': 'New headline',
'slug': 'new-headline',
'pub_date': '1988-01-04',
- 'writer': six.text_type(self.w_royko.pk),
+ 'writer': str(self.w_royko.pk),
'article': 'Hello.',
- 'categories': [six.text_type(self.c1.id), six.text_type(self.c2.id)]
+ 'categories': [str(self.c1.id), str(self.c2.id)]
}
# Create a new article, with categories, via the form.
f = ArticleForm(form_data)
@@ -1427,7 +1427,7 @@ class ModelFormBasicTests(TestCase):
# Create a new article, with categories, via the form, but use commit=False.
# The m2m data won't be saved until save_m2m() is invoked on the form.
- form_data['categories'] = [six.text_type(self.c1.id), six.text_type(self.c2.id)]
+ form_data['categories'] = [str(self.c1.id), str(self.c2.id)]
f = ArticleForm(form_data)
new_art = f.save(commit=False)
@@ -1979,12 +1979,12 @@ class ModelOneToOneFieldTests(TestCase):
)
data = {
- 'writer': six.text_type(self.w_woodward.pk),
+ 'writer': str(self.w_woodward.pk),
'age': '65',
}
form = WriterProfileForm(data)
instance = form.save()
- self.assertEqual(six.text_type(instance), 'Bob Woodward is 65')
+ self.assertEqual(str(instance), 'Bob Woodward is 65')
form = WriterProfileForm(instance=instance)
self.assertHTMLEqual(
@@ -2062,14 +2062,14 @@ class FileAndImageFieldTests(TestCase):
fields = '__all__'
form = DocumentForm()
- self.assertIn('name="myfile"', six.text_type(form))
- self.assertNotIn('myfile-clear', six.text_type(form))
+ self.assertIn('name="myfile"', str(form))
+ self.assertNotIn('myfile-clear', str(form))
form = DocumentForm(files={'myfile': SimpleUploadedFile('something.txt', b'content')})
self.assertTrue(form.is_valid())
doc = form.save(commit=False)
self.assertEqual(doc.myfile.name, 'something.txt')
form = DocumentForm(instance=doc)
- self.assertIn('myfile-clear', six.text_type(form))
+ self.assertIn('myfile-clear', str(form))
form = DocumentForm(instance=doc, data={'myfile-clear': 'true'})
doc = form.save(commit=False)
self.assertFalse(doc.myfile)
@@ -2094,7 +2094,7 @@ class FileAndImageFieldTests(TestCase):
self.assertTrue(not form.is_valid())
self.assertEqual(form.errors['myfile'],
['Please either submit a file or check the clear checkbox, not both.'])
- rendered = six.text_type(form)
+ rendered = str(form)
self.assertIn('something.txt', rendered)
self.assertIn('myfile-clear', rendered)
@@ -2469,7 +2469,7 @@ class OtherModelFormTests(TestCase):
# the ModelForm.
f = ModelFormWithMedia()
self.assertHTMLEqual(
- six.text_type(f.media),
+ str(f.media),
'''<link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/some/form/javascript"></script>'''
)
@@ -2520,7 +2520,7 @@ class OtherModelFormTests(TestCase):
(22, 'Pear')))
form = InventoryForm(instance=core)
- self.assertHTMLEqual(six.text_type(form['parent']), '''<select name="parent" id="id_parent">
+ self.assertHTMLEqual(str(form['parent']), '''<select name="parent" id="id_parent">
<option value="">---------</option>
<option value="86" selected>Apple</option>
<option value="87">Core</option>
@@ -2543,7 +2543,7 @@ class OtherModelFormTests(TestCase):
['description', 'url'])
self.assertHTMLEqual(
- six.text_type(CategoryForm()),
+ str(CategoryForm()),
'''<tr><th><label for="id_description">Description:</label></th>
<td><input type="text" name="description" id="id_description" required /></td></tr>
<tr><th><label for="id_url">The URL:</label></th>
@@ -2564,7 +2564,7 @@ class OtherModelFormTests(TestCase):
self.assertEqual(list(CustomFieldForExclusionForm.base_fields),
['name'])
self.assertHTMLEqual(
- six.text_type(CustomFieldForExclusionForm()),
+ str(CustomFieldForExclusionForm()),
'''<tr><th><label for="id_name">Name:</label></th>
<td><input id="id_name" type="text" name="name" maxlength="10" required /></td></tr>'''
)