diff options
| author | Vytis Banaitis <vytis.banaitis@gmail.com> | 2017-01-20 23:04:05 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-01-26 08:19:27 -0500 |
| commit | d1bab24e0144d14513a1411503c95ececb425188 (patch) | |
| tree | 187452bf7b66a9600abc47570ccae22e6d539ede /tests | |
| parent | 888c1e9bfe49135d049cbdcbbb0f2e97a1a0a1f5 (diff) | |
Refs #23919, #27778 -- Removed obsolete mentions of unicode.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/tests.py | 4 | ||||
| -rw-r--r-- | tests/datatypes/tests.py | 5 | ||||
| -rw-r--r-- | tests/forms_tests/widget_tests/test_clearablefileinput.py | 2 | ||||
| -rw-r--r-- | tests/forms_tests/widget_tests/test_timeinput.py | 4 | ||||
| -rw-r--r-- | tests/httpwrappers/tests.py | 6 | ||||
| -rw-r--r-- | tests/m2m_and_m2o/models.py | 4 | ||||
| -rw-r--r-- | tests/m2m_and_m2o/tests.py | 8 | ||||
| -rw-r--r-- | tests/many_to_many/models.py | 2 | ||||
| -rw-r--r-- | tests/many_to_one/tests.py | 5 | ||||
| -rw-r--r-- | tests/model_regress/models.py | 2 | ||||
| -rw-r--r-- | tests/model_regress/tests.py | 8 | ||||
| -rw-r--r-- | tests/queries/tests.py | 3 | ||||
| -rw-r--r-- | tests/signing/tests.py | 2 | ||||
| -rw-r--r-- | tests/template_tests/syntax_tests/test_filter_syntax.py | 3 | ||||
| -rw-r--r-- | tests/template_tests/test_loaders.py | 2 | ||||
| -rw-r--r-- | tests/template_tests/test_unicode.py | 6 | ||||
| -rw-r--r-- | tests/template_tests/utils.py | 2 | ||||
| -rw-r--r-- | tests/test_client_regress/tests.py | 2 |
18 files changed, 29 insertions, 41 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py index 214852ea77..284a878172 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -411,9 +411,7 @@ class LastExecutedQueryTest(TestCase): self.assertIn(Reporter._meta.db_table, sql) def test_query_encoding(self): - """ - last_executed_query() returns an Unicode string - """ + """last_executed_query() returns a string.""" data = RawData.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1}) sql, params = data.query.sql_with_params() cursor = data.query.get_compiler('default').execute_sql(CURSOR) diff --git a/tests/datatypes/tests.py b/tests/datatypes/tests.py index 5c3dffa457..52f24fe051 100644 --- a/tests/datatypes/tests.py +++ b/tests/datatypes/tests.py @@ -69,9 +69,8 @@ class DataTypesTestCase(TestCase): self.assertEqual(0, Donut.objects.filter(consumed_at__year=2005).count()) self.assertEqual(0, Donut.objects.filter(consumed_at__year=2008).count()) - def test_textfields_unicode(self): - """Regression test for #10238: TextField values returned from the - database should be unicode.""" + def test_textfields_str(self): + """TextField values returned from the database should be str.""" d = Donut.objects.create(name='Jelly Donut', review='Outstanding') newd = Donut.objects.get(id=d.id) self.assertIsInstance(newd.review, str) diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py index eea7054541..3250f6e98e 100644 --- a/tests/forms_tests/widget_tests/test_clearablefileinput.py +++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py @@ -6,7 +6,7 @@ from .base import WidgetTest class FakeFieldFile: """ - Quacks like a FieldFile (has a .url and unicode representation), but + Quacks like a FieldFile (has a .url and string representation), but doesn't require us to care about storages etc. """ url = 'something' diff --git a/tests/forms_tests/widget_tests/test_timeinput.py b/tests/forms_tests/widget_tests/test_timeinput.py index 96fb04e24c..ab355e2ec9 100644 --- a/tests/forms_tests/widget_tests/test_timeinput.py +++ b/tests/forms_tests/widget_tests/test_timeinput.py @@ -28,9 +28,7 @@ class TimeInputTest(WidgetTest): )) def test_string(self): - """ - We should be able to initialize from a unicode value. - """ + """Initializing from a string value.""" self.check_html(self.widget, 'time', '13:12:11', html=( '<input type="text" name="time" value="13:12:11" />' )) diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index c58163b014..800b584fe5 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -280,7 +280,7 @@ class HttpResponseTests(unittest.TestCase): def test_headers_type(self): r = HttpResponse() - # ASCII unicode or bytes values are converted to strings. + # ASCII strings or bytes values are converted to strings. r['key'] = 'test' self.assertEqual(r['key'], 'test') r['key'] = 'test'.encode('ascii') @@ -296,7 +296,7 @@ class HttpResponseTests(unittest.TestCase): self.assertEqual(r['key'], '=?utf-8?b?4oCg?=') self.assertIn(b'=?utf-8?b?4oCg?=', r.serialize_headers()) - # The response also converts unicode or bytes keys to strings, but requires + # The response also converts string or bytes keys to strings, but requires # them to contain ASCII r = HttpResponse() del r['Content-Type'] @@ -570,7 +570,7 @@ class StreamingHttpResponseTests(SimpleTestCase): self.assertEqual(list(r), [b'abc', b'def']) self.assertEqual(list(r), []) - # iterating over Unicode strings still yields bytestring chunks. + # iterating over strings still yields bytestring chunks. r.streaming_content = iter(['hello', 'café']) chunks = list(r) # '\xc3\xa9' == unichr(233).encode('utf-8') diff --git a/tests/m2m_and_m2o/models.py b/tests/m2m_and_m2o/models.py index d9da2bf534..9e3cf7c1da 100644 --- a/tests/m2m_and_m2o/models.py +++ b/tests/m2m_and_m2o/models.py @@ -22,5 +22,5 @@ class Issue(models.Model): ordering = ('num',) -class UnicodeReferenceModel(models.Model): - others = models.ManyToManyField("UnicodeReferenceModel") +class StringReferenceModel(models.Model): + others = models.ManyToManyField('StringReferenceModel') diff --git a/tests/m2m_and_m2o/tests.py b/tests/m2m_and_m2o/tests.py index 2c84a7f2d4..aa5daa9d1d 100644 --- a/tests/m2m_and_m2o/tests.py +++ b/tests/m2m_and_m2o/tests.py @@ -1,7 +1,7 @@ from django.db.models import Q from django.test import TestCase -from .models import Issue, UnicodeReferenceModel, User +from .models import Issue, StringReferenceModel, User class RelatedObjectTests(TestCase): @@ -84,11 +84,11 @@ class RelatedObjectTests(TestCase): class RelatedObjectUnicodeTests(TestCase): def test_m2m_with_unicode_reference(self): """ - Regression test for #6045: references to other models can be unicode + Regression test for #6045: references to other models can be strings, providing they are directly convertible to ASCII. """ - m1 = UnicodeReferenceModel.objects.create() - m2 = UnicodeReferenceModel.objects.create() + m1 = StringReferenceModel.objects.create() + m2 = StringReferenceModel.objects.create() m2.others.add(m1) # used to cause an error (see ticket #6045) m2.save() list(m2.others.all()) # Force retrieval. diff --git a/tests/many_to_many/models.py b/tests/many_to_many/models.py index cf3add7848..22911654ab 100644 --- a/tests/many_to_many/models.py +++ b/tests/many_to_many/models.py @@ -29,7 +29,7 @@ class Tag(models.Model): class Article(models.Model): headline = models.CharField(max_length=100) - # Assign a unicode string as name to make sure the intermediary model is + # Assign a string as name to make sure the intermediary model is # correctly created. Refs #20207 publications = models.ManyToManyField(Publication, name='publications') tags = models.ManyToManyField(Tag, related_name='tags') diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index 478a746669..52ddcc8cfe 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -28,9 +28,6 @@ class ManyToOneTests(TestCase): # Article objects have access to their related Reporter objects. r = self.a.reporter self.assertEqual(r.id, self.r.id) - # These are strings instead of unicode strings because that's what was used in - # the creation of this reporter (and we haven't refreshed the data from the - # database, which always returns unicode strings). self.assertEqual((r.first_name, self.r.last_name), ('John', 'Smith')) def test_create(self): @@ -200,7 +197,7 @@ class ManyToOneTests(TestCase): where=["many_to_one_reporter.last_name='Smith'"]), ["<Article: John's second story>", "<Article: This is a test>"] ) - # ... and should work fine with the unicode that comes out of forms.Form.cleaned_data + # ... and should work fine with the string that comes out of forms.Form.cleaned_data self.assertQuerysetEqual( (Article.objects .filter(reporter__first_name__exact='John') diff --git a/tests/model_regress/models.py b/tests/model_regress/models.py index 3208db90b8..7af20e44d3 100644 --- a/tests/model_regress/models.py +++ b/tests/model_regress/models.py @@ -52,7 +52,7 @@ class Worker(models.Model): return self.name -class BrokenUnicodeMethod(models.Model): +class BrokenStrMethod(models.Model): name = models.CharField(max_length=7) def __str__(self): diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py index e9374d9d93..1988a3fd09 100644 --- a/tests/model_regress/tests.py +++ b/tests/model_regress/tests.py @@ -8,7 +8,7 @@ from django.test import TestCase, skipUnlessDBFeature from django.utils.timezone import get_fixed_timezone from .models import ( - Article, BrokenUnicodeMethod, Department, Event, Model1, Model2, Model3, + Article, BrokenStrMethod, Department, Event, Model1, Model2, Model3, NonAutoPK, Party, Worker, ) @@ -187,9 +187,9 @@ class ModelTests(TestCase): self.assertEqual(str(w), "Full-time") def test_broken_unicode(self): - # Models with broken unicode methods should still have a printable repr - b = BrokenUnicodeMethod.objects.create(name="Jerry") - self.assertEqual(repr(b), "<BrokenUnicodeMethod: [Bad Unicode data]>") + # Models with broken __str__() methods have a printable repr(). + b = BrokenStrMethod.objects.create(name='Jerry') + self.assertEqual(repr(b), '<BrokenStrMethod: [Bad Unicode data]>') @skipUnlessDBFeature("supports_timezones") def test_timezones(self): diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 4107dada0e..8fe2af644f 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -553,9 +553,6 @@ class Queries1Tests(TestCase): s.reverse() params.reverse() - # This slightly odd comparison works around the fact that PostgreSQL will - # return 'one' and 'two' as strings, not Unicode objects. It's a side-effect of - # using constants here and not a real concern. d = Item.objects.extra(select=OrderedDict(s), select_params=params).values('a', 'b')[0] self.assertEqual(d, {'a': 'one', 'b': 'two'}) diff --git a/tests/signing/tests.py b/tests/signing/tests.py index a55457efdd..01dd55fcfe 100644 --- a/tests/signing/tests.py +++ b/tests/signing/tests.py @@ -69,7 +69,7 @@ class TestSigner(SimpleTestCase): "dumps and loads be reversible for any JSON serializable object" objects = [ ['a', 'list'], - 'a unicode string \u2019', + 'a string \u2019', {'a': 'dictionary'}, ] for o in objects: diff --git a/tests/template_tests/syntax_tests/test_filter_syntax.py b/tests/template_tests/syntax_tests/test_filter_syntax.py index c8d764659a..738b3ed978 100644 --- a/tests/template_tests/syntax_tests/test_filter_syntax.py +++ b/tests/template_tests/syntax_tests/test_filter_syntax.py @@ -160,8 +160,7 @@ class FilterSyntaxTests(SimpleTestCase): @setup({'filter-syntax18': r'{{ var }}'}) def test_filter_syntax18(self): """ - Make sure that any unicode strings are converted to bytestrings - in the final output. + Strings are converted to bytestrings in the final output. """ output = self.engine.render_to_string('filter-syntax18', {'var': UTF8Class()}) self.assertEqual(output, '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') diff --git a/tests/template_tests/test_loaders.py b/tests/template_tests/test_loaders.py index b90586a078..5c81164bb5 100644 --- a/tests/template_tests/test_loaders.py +++ b/tests/template_tests/test_loaders.py @@ -158,7 +158,7 @@ class FileSystemLoaderTests(SimpleTestCase): with self.source_checker(['/dir1', '/dir2']) as check_sources: # UTF-8 bytestrings are permitted. check_sources(b'\xc3\x85ngstr\xc3\xb6m', ['/dir1/Ångström', '/dir2/Ångström']) - # Unicode strings are permitted. + # Strings are permitted. check_sources('Ångström', ['/dir1/Ångström', '/dir2/Ångström']) def test_utf8_bytestring(self): diff --git a/tests/template_tests/test_unicode.py b/tests/template_tests/test_unicode.py index dbd18eb495..42682166f5 100644 --- a/tests/template_tests/test_unicode.py +++ b/tests/template_tests/test_unicode.py @@ -7,7 +7,7 @@ from django.utils.safestring import SafeData class UnicodeTests(TestCase): def test_template(self): - # Templates can be created from unicode strings. + # Templates can be created from strings. engine = Engine() t1 = engine.from_string('ŠĐĆŽćžšđ {{ var }}') # Templates can also be created from bytestrings. These are assumed to @@ -17,14 +17,14 @@ class UnicodeTests(TestCase): with self.assertRaises(TemplateEncodingError): engine.from_string(b'\x80\xc5\xc0') - # Contexts can be constructed from unicode or UTF-8 bytestrings. + # Contexts can be constructed from strings or UTF-8 bytestrings. Context({b"var": b"foo"}) Context({"var": b"foo"}) c3 = Context({b"var": "Đđ"}) Context({"var": b"\xc4\x90\xc4\x91"}) # Since both templates and all four contexts represent the same thing, - # they all render the same (and are returned as unicode objects and + # they all render the same (and are returned as strings and # "safe" objects as well, for auto-escaping purposes). self.assertEqual(t1.render(c3), t2.render(c3)) self.assertIsInstance(t1.render(c3), str) diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py index 3ebacf7bcb..66a173396c 100644 --- a/tests/template_tests/utils.py +++ b/tests/template_tests/utils.py @@ -169,7 +169,7 @@ class UTF8Class: return 'ŠĐĆŽćžšđ' -# These two classes are used to test auto-escaping of unicode output. +# These two classes are used to test auto-escaping of string output. class UnsafeClass: def __str__(self): return 'you & me' diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py index d3263d07a6..e5f9eb97b9 100644 --- a/tests/test_client_regress/tests.py +++ b/tests/test_client_regress/tests.py @@ -1266,7 +1266,7 @@ class QueryStringTests(SimpleTestCase): class UnicodePayloadTests(SimpleTestCase): def test_simple_unicode_payload(self): - "A simple ASCII-only unicode JSON document can be POSTed" + "A simple ASCII-only JSON document can be POSTed" # Regression test for #10571 json = '{"english": "mountain pass"}' response = self.client.post("/parse_unicode_json/", json, content_type="application/json") |
