summaryrefslogtreecommitdiff
path: root/tests/model_fields/test_promises.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/model_fields/test_promises.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/model_fields/test_promises.py')
-rw-r--r--tests/model_fields/test_promises.py69
1 files changed, 47 insertions, 22 deletions
diff --git a/tests/model_fields/test_promises.py b/tests/model_fields/test_promises.py
index f48a4cc34a..bfc09f590d 100644
--- a/tests/model_fields/test_promises.py
+++ b/tests/model_fields/test_promises.py
@@ -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)