From 2aaabe2004e1953eb7d7057edcf2fabd37f7394d Mon Sep 17 00:00:00 2001 From: oliver Date: Fri, 22 Mar 2019 07:05:29 +0900 Subject: [PATCH] Used QuerySet.bulk_create() in a couple of postgres tests. Follow up to 0ce2ad9ca4623cfd6dc2515430c0ae8a1717a607. --- tests/postgres_tests/test_json.py | 28 ++++++++++++++-------------- tests/postgres_tests/test_ranges.py | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/postgres_tests/test_json.py b/tests/postgres_tests/test_json.py index ca164a81ba..eab7f8a272 100644 --- a/tests/postgres_tests/test_json.py +++ b/tests/postgres_tests/test_json.py @@ -104,19 +104,19 @@ class TestSaveLoad(PostgreSQLTestCase): class TestQuerying(PostgreSQLTestCase): @classmethod def setUpTestData(cls): - cls.objs = [ - JSONModel.objects.create(field=None), - JSONModel.objects.create(field=True), - JSONModel.objects.create(field=False), - JSONModel.objects.create(field='yes'), - JSONModel.objects.create(field=7), - JSONModel.objects.create(field=[]), - JSONModel.objects.create(field={}), - JSONModel.objects.create(field={ + cls.objs = JSONModel.objects.bulk_create([ + JSONModel(field=None), + JSONModel(field=True), + JSONModel(field=False), + JSONModel(field='yes'), + JSONModel(field=7), + JSONModel(field=[]), + JSONModel(field={}), + JSONModel(field={ 'a': 'b', 'c': 1, }), - JSONModel.objects.create(field={ + JSONModel(field={ 'a': 'b', 'c': 1, 'd': ['e', {'f': 'g'}], @@ -125,13 +125,13 @@ class TestQuerying(PostgreSQLTestCase): 'j': None, 'k': {'l': 'm'}, }), - JSONModel.objects.create(field=[1, [2]]), - JSONModel.objects.create(field={ + JSONModel(field=[1, [2]]), + JSONModel(field={ 'k': True, 'l': False, }), - JSONModel.objects.create(field={'foo': 'bar'}), - ] + JSONModel(field={'foo': 'bar'}), + ]) def test_exact(self): self.assertSequenceEqual( diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index f4e7e9bd6d..ae834b6ff0 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -167,13 +167,13 @@ class TestQuerying(PostgreSQLTestCase): @classmethod def setUpTestData(cls): - cls.objs = [ - RangesModel.objects.create(ints=NumericRange(0, 10)), - RangesModel.objects.create(ints=NumericRange(5, 15)), - RangesModel.objects.create(ints=NumericRange(None, 0)), - RangesModel.objects.create(ints=NumericRange(empty=True)), - RangesModel.objects.create(ints=None), - ] + cls.objs = RangesModel.objects.bulk_create([ + RangesModel(ints=NumericRange(0, 10)), + RangesModel(ints=NumericRange(5, 15)), + RangesModel(ints=NumericRange(None, 0)), + RangesModel(ints=NumericRange(empty=True)), + RangesModel(ints=None), + ]) def test_exact(self): self.assertSequenceEqual(