summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-11-23 20:59:38 -0500
committerTim Graham <timograham@gmail.com>2018-11-27 09:35:17 -0500
commit84e7a9f4a7bb3cad2bffae97baaae99de152c451 (patch)
treec81eeb6edf47ce0abdb7551cd28a3de354dfd20f /tests/postgres_tests/test_array.py
parent9a7d336c3866c5226ed11868be0234c7e2fa47fa (diff)
Switched setUp() to setUpTestData() where possible in Django's tests.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py55
1 files changed, 29 insertions, 26 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 9c678bb588..f878ad3fb5 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -138,14 +138,15 @@ class TestSaveLoad(PostgreSQLTestCase):
class TestQuerying(PostgreSQLTestCase):
- def setUp(self):
- self.objs = [
- NullableIntegerArrayModel.objects.create(field=[1]),
- NullableIntegerArrayModel.objects.create(field=[2]),
- NullableIntegerArrayModel.objects.create(field=[2, 3]),
- NullableIntegerArrayModel.objects.create(field=[20, 30, 40]),
- NullableIntegerArrayModel.objects.create(field=None),
- ]
+ @classmethod
+ def setUpTestData(cls):
+ cls.objs = NullableIntegerArrayModel.objects.bulk_create([
+ NullableIntegerArrayModel(field=[1]),
+ NullableIntegerArrayModel(field=[2]),
+ NullableIntegerArrayModel(field=[2, 3]),
+ NullableIntegerArrayModel(field=[20, 30, 40]),
+ NullableIntegerArrayModel(field=None),
+ ])
def test_exact(self):
self.assertSequenceEqual(
@@ -368,16 +369,17 @@ class TestQuerying(PostgreSQLTestCase):
class TestDateTimeExactQuerying(PostgreSQLTestCase):
- def setUp(self):
+ @classmethod
+ def setUpTestData(cls):
now = timezone.now()
- self.datetimes = [now]
- self.dates = [now.date()]
- self.times = [now.time()]
- self.objs = [
+ cls.datetimes = [now]
+ cls.dates = [now.date()]
+ cls.times = [now.time()]
+ cls.objs = [
DateTimeArrayModel.objects.create(
- datetimes=self.datetimes,
- dates=self.dates,
- times=self.times,
+ datetimes=cls.datetimes,
+ dates=cls.dates,
+ times=cls.times,
)
]
@@ -402,17 +404,18 @@ class TestDateTimeExactQuerying(PostgreSQLTestCase):
class TestOtherTypesExactQuerying(PostgreSQLTestCase):
- def setUp(self):
- self.ips = ['192.168.0.1', '::1']
- self.uuids = [uuid.uuid4()]
- self.decimals = [decimal.Decimal(1.25), 1.75]
- self.tags = [Tag(1), Tag(2), Tag(3)]
- self.objs = [
+ @classmethod
+ def setUpTestData(cls):
+ cls.ips = ['192.168.0.1', '::1']
+ cls.uuids = [uuid.uuid4()]
+ cls.decimals = [decimal.Decimal(1.25), 1.75]
+ cls.tags = [Tag(1), Tag(2), Tag(3)]
+ cls.objs = [
OtherTypesArrayModel.objects.create(
- ips=self.ips,
- uuids=self.uuids,
- decimals=self.decimals,
- tags=self.tags,
+ ips=cls.ips,
+ uuids=cls.uuids,
+ decimals=cls.decimals,
+ tags=cls.tags,
)
]