1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #33476 -- Reformatted code with Black.

This commit is contained in:
django-bot
2022-02-03 20:24:19 +01:00
committed by Mariusz Felisiak
parent f68fa8b45d
commit 9c19aff7c7
1992 changed files with 139577 additions and 96284 deletions

View File

@@ -8,31 +8,34 @@ from ..models import Author
class TrimTests(TestCase):
def test_trim(self):
Author.objects.create(name=' John ', alias='j')
Author.objects.create(name='Rhonda', alias='r')
Author.objects.create(name=" John ", alias="j")
Author.objects.create(name="Rhonda", alias="r")
authors = Author.objects.annotate(
ltrim=LTrim('name'),
rtrim=RTrim('name'),
trim=Trim('name'),
ltrim=LTrim("name"),
rtrim=RTrim("name"),
trim=Trim("name"),
)
self.assertQuerysetEqual(
authors.order_by('alias'), [
('John ', ' John', 'John'),
('Rhonda', 'Rhonda', 'Rhonda'),
authors.order_by("alias"),
[
("John ", " John", "John"),
("Rhonda", "Rhonda", "Rhonda"),
],
lambda a: (a.ltrim, a.rtrim, a.trim)
lambda a: (a.ltrim, a.rtrim, a.trim),
)
def test_trim_transform(self):
Author.objects.create(name=' John ')
Author.objects.create(name='Rhonda')
Author.objects.create(name=" John ")
Author.objects.create(name="Rhonda")
tests = (
(LTrim, 'John '),
(RTrim, ' John'),
(Trim, 'John'),
(LTrim, "John "),
(RTrim, " John"),
(Trim, "John"),
)
for transform, trimmed_name in tests:
with self.subTest(transform=transform):
with register_lookup(CharField, transform):
authors = Author.objects.filter(**{'name__%s' % transform.lookup_name: trimmed_name})
self.assertQuerysetEqual(authors, [' John '], lambda a: a.name)
authors = Author.objects.filter(
**{"name__%s" % transform.lookup_name: trimmed_name}
)
self.assertQuerysetEqual(authors, [" John "], lambda a: a.name)