瀏覽代碼

Refs #27996 -- Skipped RandomUUID test on PostgreSQL 9.3.

Tim Graham 7 年之前
父節點
當前提交
650bf6714d
共有 3 個文件被更改,包括 14 次插入1 次删除
  1. 2 0
      docs/ref/contrib/postgres/functions.txt
  2. 10 0
      tests/postgres_tests/__init__.py
  3. 2 1
      tests/postgres_tests/test_functions.py

+ 2 - 0
docs/ref/contrib/postgres/functions.txt

@@ -16,6 +16,8 @@ All of these functions are available from the
 
 Returns a version 4 UUID.
 
+Requires PostgreSQL 9.4 or greater.
+
 The `pgcrypto extension`_ must be installed. You can use the
 :class:`~django.contrib.postgres.operations.CryptoExtension` migration
 operation to install it.

+ 10 - 0
tests/postgres_tests/__init__.py

@@ -7,6 +7,16 @@ from django.db.backends.signals import connection_created
 from django.test import TestCase, modify_settings
 
 
+def skipUnlessPG94(test):
+    try:
+        PG_VERSION = connection.pg_version
+    except AttributeError:
+        PG_VERSION = 0
+    if PG_VERSION < 90400:
+        return unittest.skip('PostgreSQL ≥ 9.4 required')(test)
+    return test
+
+
 @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests")
 class PostgreSQLTestCase(TestCase):
     @classmethod

+ 2 - 1
tests/postgres_tests/test_functions.py

@@ -4,7 +4,7 @@ from time import sleep
 
 from django.contrib.postgres.functions import RandomUUID, TransactionNow
 
-from . import PostgreSQLTestCase
+from . import PostgreSQLTestCase, skipUnlessPG94
 from .models import NowTestModel, UUIDTestModel
 
 
@@ -29,6 +29,7 @@ class TestTransactionNow(PostgreSQLTestCase):
         self.assertEqual(m1.when, m2.when)
 
 
+@skipUnlessPG94
 class TestRandomUUID(PostgreSQLTestCase):
 
     def test_random_uuid(self):