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

@@ -2,24 +2,43 @@ import datetime
from decimal import Decimal
from django.db.models import (
AutoField, BinaryField, BooleanField, CharField, DateField, DateTimeField,
DecimalField, EmailField, FileField, FilePathField, FloatField,
GenericIPAddressField, ImageField, IntegerField, IPAddressField,
PositiveBigIntegerField, PositiveIntegerField, PositiveSmallIntegerField,
SlugField, SmallIntegerField, TextField, TimeField, URLField,
AutoField,
BinaryField,
BooleanField,
CharField,
DateField,
DateTimeField,
DecimalField,
EmailField,
FileField,
FilePathField,
FloatField,
GenericIPAddressField,
ImageField,
IntegerField,
IPAddressField,
PositiveBigIntegerField,
PositiveIntegerField,
PositiveSmallIntegerField,
SlugField,
SmallIntegerField,
TextField,
TimeField,
URLField,
)
from django.test import SimpleTestCase
from django.utils.functional import lazy
class PromiseTest(SimpleTestCase):
def test_AutoField(self):
lazy_func = lazy(lambda: 1, int)
self.assertIsInstance(AutoField(primary_key=True).get_prep_value(lazy_func()), int)
self.assertIsInstance(
AutoField(primary_key=True).get_prep_value(lazy_func()), int
)
def test_BinaryField(self):
lazy_func = lazy(lambda: b'', bytes)
lazy_func = lazy(lambda: b"", bytes)
self.assertIsInstance(BinaryField().get_prep_value(lazy_func()), bytes)
def test_BooleanField(self):
@@ -27,7 +46,7 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(BooleanField().get_prep_value(lazy_func()), bool)
def test_CharField(self):
lazy_func = lazy(lambda: '', str)
lazy_func = lazy(lambda: "", str)
self.assertIsInstance(CharField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(CharField().get_prep_value(lazy_func()), str)
@@ -38,24 +57,26 @@ class PromiseTest(SimpleTestCase):
def test_DateTimeField(self):
lazy_func = lazy(lambda: datetime.datetime.now(), datetime.datetime)
self.assertIsInstance(DateTimeField().get_prep_value(lazy_func()), datetime.datetime)
self.assertIsInstance(
DateTimeField().get_prep_value(lazy_func()), datetime.datetime
)
def test_DecimalField(self):
lazy_func = lazy(lambda: Decimal('1.2'), Decimal)
lazy_func = lazy(lambda: Decimal("1.2"), Decimal)
self.assertIsInstance(DecimalField().get_prep_value(lazy_func()), Decimal)
def test_EmailField(self):
lazy_func = lazy(lambda: 'mailbox@domain.com', str)
lazy_func = lazy(lambda: "mailbox@domain.com", str)
self.assertIsInstance(EmailField().get_prep_value(lazy_func()), str)
def test_FileField(self):
lazy_func = lazy(lambda: 'filename.ext', str)
lazy_func = lazy(lambda: "filename.ext", str)
self.assertIsInstance(FileField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(FileField().get_prep_value(lazy_func()), str)
def test_FilePathField(self):
lazy_func = lazy(lambda: 'tests.py', str)
lazy_func = lazy(lambda: "tests.py", str)
self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), str)
@@ -65,7 +86,7 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(FloatField().get_prep_value(lazy_func()), float)
def test_ImageField(self):
lazy_func = lazy(lambda: 'filename.ext', str)
lazy_func = lazy(lambda: "filename.ext", str)
self.assertIsInstance(ImageField().get_prep_value(lazy_func()), str)
def test_IntegerField(self):
@@ -73,13 +94,13 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(IntegerField().get_prep_value(lazy_func()), int)
def test_IPAddressField(self):
lazy_func = lazy(lambda: '127.0.0.1', str)
lazy_func = lazy(lambda: "127.0.0.1", str)
self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), str)
def test_GenericIPAddressField(self):
lazy_func = lazy(lambda: '127.0.0.1', str)
lazy_func = lazy(lambda: "127.0.0.1", str)
self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), str)
@@ -90,14 +111,18 @@ class PromiseTest(SimpleTestCase):
def test_PositiveSmallIntegerField(self):
lazy_func = lazy(lambda: 1, int)
self.assertIsInstance(PositiveSmallIntegerField().get_prep_value(lazy_func()), int)
self.assertIsInstance(
PositiveSmallIntegerField().get_prep_value(lazy_func()), int
)
def test_PositiveBigIntegerField(self):
lazy_func = lazy(lambda: 1, int)
self.assertIsInstance(PositiveBigIntegerField().get_prep_value(lazy_func()), int)
self.assertIsInstance(
PositiveBigIntegerField().get_prep_value(lazy_func()), int
)
def test_SlugField(self):
lazy_func = lazy(lambda: 'slug', str)
lazy_func = lazy(lambda: "slug", str)
self.assertIsInstance(SlugField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(SlugField().get_prep_value(lazy_func()), str)
@@ -107,7 +132,7 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(SmallIntegerField().get_prep_value(lazy_func()), int)
def test_TextField(self):
lazy_func = lazy(lambda: 'Abc', str)
lazy_func = lazy(lambda: "Abc", str)
self.assertIsInstance(TextField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(TextField().get_prep_value(lazy_func()), str)
@@ -117,5 +142,5 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(TimeField().get_prep_value(lazy_func()), datetime.time)
def test_URLField(self):
lazy_func = lazy(lambda: 'http://domain.com', str)
lazy_func = lazy(lambda: "http://domain.com", str)
self.assertIsInstance(URLField().get_prep_value(lazy_func()), str)