From 36f1f5cfb008c465f372389080cdd92671a6cab7 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 12 Feb 2016 09:59:13 -0500 Subject: [PATCH] Refs #25979 -- Dropped compatiblity for running tests on PostgreSQL < 9.2. --- .../migrations/0002_create_test_models.py | 5 --- tests/postgres_tests/models.py | 35 +++++++------------ tests/postgres_tests/test_ranges.py | 26 +++----------- 3 files changed, 18 insertions(+), 48 deletions(-) diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py index 4be219f722..a58119e23c 100644 --- a/tests/postgres_tests/migrations/0002_create_test_models.py +++ b/tests/postgres_tests/migrations/0002_create_test_models.py @@ -141,9 +141,6 @@ class Migration(migrations.Migration): ('when', models.DateTimeField(null=True, default=None)), ] ), - ] - - pg_92_operations = [ migrations.CreateModel( name='RangesModel', fields=[ @@ -199,8 +196,6 @@ class Migration(migrations.Migration): except AttributeError: pass # We are probably not on PostgreSQL else: - if PG_VERSION >= 90200: - self.operations = self.operations + self.pg_92_operations if PG_VERSION >= 90400: self.operations = self.operations + self.pg_94_operations return super(Migration, self).apply(project_state, schema_editor, collect_sql) diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index 22d43b2438..62a32b113d 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -52,30 +52,21 @@ class TextFieldModel(models.Model): field = models.TextField() -# Only create this model for postgres >= 9.2 -if connection.vendor == 'postgresql' and connection.pg_version >= 90200: - class RangesModel(PostgreSQLModel): - ints = IntegerRangeField(blank=True, null=True) - bigints = BigIntegerRangeField(blank=True, null=True) - floats = FloatRangeField(blank=True, null=True) - timestamps = DateTimeRangeField(blank=True, null=True) - dates = DateRangeField(blank=True, null=True) +class RangesModel(PostgreSQLModel): + ints = IntegerRangeField(blank=True, null=True) + bigints = BigIntegerRangeField(blank=True, null=True) + floats = FloatRangeField(blank=True, null=True) + timestamps = DateTimeRangeField(blank=True, null=True) + dates = DateRangeField(blank=True, null=True) - class RangeLookupsModel(PostgreSQLModel): - parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True) - integer = models.IntegerField(blank=True, null=True) - big_integer = models.BigIntegerField(blank=True, null=True) - float = models.FloatField(blank=True, null=True) - timestamp = models.DateTimeField(blank=True, null=True) - date = models.DateField(blank=True, null=True) -else: - # create an object with this name so we don't have failing imports - class RangesModel(object): - pass - - class RangeLookupsModel(object): - pass +class RangeLookupsModel(PostgreSQLModel): + parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True) + integer = models.IntegerField(blank=True, null=True) + big_integer = models.BigIntegerField(blank=True, null=True) + float = models.FloatField(blank=True, null=True) + timestamp = models.DateTimeField(blank=True, null=True) + date = models.DateField(blank=True, null=True) # Only create this model for postgres >= 9.4 diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index 3ebcb5b670..dd676f96be 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -1,12 +1,10 @@ import datetime import json -import unittest from django import forms from django.core import exceptions, serializers -from django.db import connection from django.db.models import F -from django.test import TestCase, override_settings +from django.test import override_settings from django.utils import timezone from . import PostgreSQLTestCase @@ -22,18 +20,7 @@ except ImportError: pass -def skipUnlessPG92(test): - try: - PG_VERSION = connection.pg_version - except AttributeError: - PG_VERSION = 0 - if PG_VERSION < 90200: - return unittest.skip('PostgreSQL >= 9.2 required')(test) - return test - - -@skipUnlessPG92 -class TestSaveLoad(TestCase): +class TestSaveLoad(PostgreSQLTestCase): def test_all_fields(self): now = timezone.now() @@ -94,8 +81,7 @@ class TestSaveLoad(TestCase): self.assertIsNone(loaded.ints) -@skipUnlessPG92 -class TestQuerying(TestCase): +class TestQuerying(PostgreSQLTestCase): @classmethod def setUpTestData(cls): @@ -198,8 +184,7 @@ class TestQuerying(TestCase): ) -@skipUnlessPG92 -class TestQueryingWithRanges(TestCase): +class TestQueryingWithRanges(PostgreSQLTestCase): def test_date_range(self): objs = [ RangeLookupsModel.objects.create(date='2015-01-01'), @@ -288,8 +273,7 @@ class TestQueryingWithRanges(TestCase): ) -@skipUnlessPG92 -class TestSerialization(TestCase): +class TestSerialization(PostgreSQLTestCase): test_data = ( '[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", ' '\\"bounds\\": \\"[)\\"}", "floats": "{\\"empty\\": true}", '