mirror of
https://github.com/django/django.git
synced 2025-08-18 17:50:58 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
parent
f68fa8b45d
commit
9c19aff7c7
1992 changed files with 139577 additions and 96284 deletions
|
@ -9,22 +9,31 @@ from ..models import Author
|
|||
class ChrTests(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.john = Author.objects.create(name='John Smith', alias='smithj')
|
||||
cls.elena = Author.objects.create(name='Élena Jordan', alias='elena')
|
||||
cls.rhonda = Author.objects.create(name='Rhonda')
|
||||
cls.john = Author.objects.create(name="John Smith", alias="smithj")
|
||||
cls.elena = Author.objects.create(name="Élena Jordan", alias="elena")
|
||||
cls.rhonda = Author.objects.create(name="Rhonda")
|
||||
|
||||
def test_basic(self):
|
||||
authors = Author.objects.annotate(first_initial=Left('name', 1))
|
||||
self.assertCountEqual(authors.filter(first_initial=Chr(ord('J'))), [self.john])
|
||||
self.assertCountEqual(authors.exclude(first_initial=Chr(ord('J'))), [self.elena, self.rhonda])
|
||||
authors = Author.objects.annotate(first_initial=Left("name", 1))
|
||||
self.assertCountEqual(authors.filter(first_initial=Chr(ord("J"))), [self.john])
|
||||
self.assertCountEqual(
|
||||
authors.exclude(first_initial=Chr(ord("J"))), [self.elena, self.rhonda]
|
||||
)
|
||||
|
||||
def test_non_ascii(self):
|
||||
authors = Author.objects.annotate(first_initial=Left('name', 1))
|
||||
self.assertCountEqual(authors.filter(first_initial=Chr(ord('É'))), [self.elena])
|
||||
self.assertCountEqual(authors.exclude(first_initial=Chr(ord('É'))), [self.john, self.rhonda])
|
||||
authors = Author.objects.annotate(first_initial=Left("name", 1))
|
||||
self.assertCountEqual(authors.filter(first_initial=Chr(ord("É"))), [self.elena])
|
||||
self.assertCountEqual(
|
||||
authors.exclude(first_initial=Chr(ord("É"))), [self.john, self.rhonda]
|
||||
)
|
||||
|
||||
def test_transform(self):
|
||||
with register_lookup(IntegerField, Chr):
|
||||
authors = Author.objects.annotate(name_code_point=Ord('name'))
|
||||
self.assertCountEqual(authors.filter(name_code_point__chr=Chr(ord('J'))), [self.john])
|
||||
self.assertCountEqual(authors.exclude(name_code_point__chr=Chr(ord('J'))), [self.elena, self.rhonda])
|
||||
authors = Author.objects.annotate(name_code_point=Ord("name"))
|
||||
self.assertCountEqual(
|
||||
authors.filter(name_code_point__chr=Chr(ord("J"))), [self.john]
|
||||
)
|
||||
self.assertCountEqual(
|
||||
authors.exclude(name_code_point__chr=Chr(ord("J"))),
|
||||
[self.elena, self.rhonda],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue