1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +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

@@ -13,7 +13,7 @@ class Alarm(models.Model):
time = models.TimeField()
def __str__(self):
return '%s (%s)' % (self.time, self.desc)
return "%s (%s)" % (self.time, self.desc)
class Author(models.Model):
@@ -21,7 +21,7 @@ class Author(models.Model):
alias = models.CharField(max_length=50, null=True, blank=True)
class Meta:
ordering = ('name',)
ordering = ("name",)
class Article(models.Model):
@@ -31,7 +31,7 @@ class Article(models.Model):
slug = models.SlugField(unique=True, blank=True, null=True)
class Meta:
ordering = ('-pub_date', 'headline')
ordering = ("-pub_date", "headline")
def __str__(self):
return self.headline
@@ -42,23 +42,23 @@ class Tag(models.Model):
name = models.CharField(max_length=100)
class Meta:
ordering = ('name',)
ordering = ("name",)
class NulledTextField(models.TextField):
def get_prep_value(self, value):
return None if value == '' else value
return None if value == "" else value
@NulledTextField.register_lookup
class NulledTransform(models.Transform):
lookup_name = 'nulled'
template = 'NULL'
lookup_name = "nulled"
template = "NULL"
@NulledTextField.register_lookup
class IsNullWithNoneAsRHS(IsNull):
lookup_name = 'isnull_none_rhs'
lookup_name = "isnull_none_rhs"
can_use_none_as_rhs = True
@@ -69,7 +69,7 @@ class Season(models.Model):
class Meta:
constraints = [
models.UniqueConstraint(fields=['year'], name='season_year_unique'),
models.UniqueConstraint(fields=["year"], name="season_year_unique"),
]
def __str__(self):
@@ -77,14 +77,14 @@ class Season(models.Model):
class Game(models.Model):
season = models.ForeignKey(Season, models.CASCADE, related_name='games')
season = models.ForeignKey(Season, models.CASCADE, related_name="games")
home = models.CharField(max_length=100)
away = models.CharField(max_length=100)
class Player(models.Model):
name = models.CharField(max_length=100)
games = models.ManyToManyField(Game, related_name='players')
games = models.ManyToManyField(Game, related_name="players")
class Product(models.Model):
@@ -104,7 +104,7 @@ class Freebie(models.Model):
stock = models.ForeignObject(
Stock,
from_fields=['stock_id', 'gift_product'],
to_fields=['id', 'product'],
from_fields=["stock_id", "gift_product"],
to_fields=["id", "product"],
on_delete=models.CASCADE,
)

View File

@@ -7,18 +7,18 @@ from .models import Product, Stock
class DecimalFieldLookupTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.p1 = Product.objects.create(name='Product1', qty_target=10)
cls.p1 = Product.objects.create(name="Product1", qty_target=10)
Stock.objects.create(product=cls.p1, qty_available=5)
Stock.objects.create(product=cls.p1, qty_available=6)
cls.p2 = Product.objects.create(name='Product2', qty_target=10)
cls.p2 = Product.objects.create(name="Product2", qty_target=10)
Stock.objects.create(product=cls.p2, qty_available=5)
Stock.objects.create(product=cls.p2, qty_available=5)
cls.p3 = Product.objects.create(name='Product3', qty_target=10)
cls.p3 = Product.objects.create(name="Product3", qty_target=10)
Stock.objects.create(product=cls.p3, qty_available=5)
Stock.objects.create(product=cls.p3, qty_available=4)
cls.queryset = Product.objects.annotate(
qty_available_sum=Sum('stock__qty_available'),
).annotate(qty_needed=F('qty_target') - F('qty_available_sum'))
qty_available_sum=Sum("stock__qty_available"),
).annotate(qty_needed=F("qty_target") - F("qty_available_sum"))
def test_gt(self):
qs = self.queryset.filter(qty_needed__gt=0)

View File

@@ -22,15 +22,15 @@ class LookupTests(SimpleTestCase):
def test_repr(self):
tests = [
(Lookup(Value(1), Value('a')), "Lookup(Value(1), Value('a'))"),
(Lookup(Value(1), Value("a")), "Lookup(Value(1), Value('a'))"),
(
YearLookup(
Value(datetime(2010, 1, 1, 0, 0, 0)),
Value(datetime(2010, 1, 1, 23, 59, 59)),
),
'YearLookup('
'Value(datetime.datetime(2010, 1, 1, 0, 0)), '
'Value(datetime.datetime(2010, 1, 1, 23, 59, 59)))'
"YearLookup("
"Value(datetime.datetime(2010, 1, 1, 0, 0)), "
"Value(datetime.datetime(2010, 1, 1, 23, 59, 59)))",
),
]
for lookup, expected in tests:
@@ -52,6 +52,8 @@ class YearLookupTests(SimpleTestCase):
lhs=Value(datetime(2010, 1, 1, 0, 0, 0), output_field=DateTimeField()),
rhs=Value(datetime(2010, 1, 1, 23, 59, 59), output_field=DateTimeField()),
)
msg = 'subclasses of YearLookup must provide a get_bound_params() method'
msg = "subclasses of YearLookup must provide a get_bound_params() method"
with self.assertRaisesMessage(NotImplementedError, msg):
look_up.get_bound_params(datetime(2010, 1, 1, 0, 0, 0), datetime(2010, 1, 1, 23, 59, 59))
look_up.get_bound_params(
datetime(2010, 1, 1, 0, 0, 0), datetime(2010, 1, 1, 23, 59, 59)
)

View File

@@ -4,13 +4,12 @@ from .models import Alarm
class TimeFieldLookupTests(TestCase):
@classmethod
def setUpTestData(self):
# Create a few Alarms
self.al1 = Alarm.objects.create(desc='Early', time='05:30')
self.al2 = Alarm.objects.create(desc='Late', time='10:00')
self.al3 = Alarm.objects.create(desc='Precise', time='12:34:56')
self.al1 = Alarm.objects.create(desc="Early", time="05:30")
self.al2 = Alarm.objects.create(desc="Late", time="10:00")
self.al3 = Alarm.objects.create(desc="Precise", time="12:34:56")
def test_hour_lookups(self):
self.assertSequenceEqual(

File diff suppressed because it is too large Load Diff