From da5747f8e460ea2a2d16f124463b3975ccfc0992 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 14 Sep 2015 18:19:19 +0200 Subject: [PATCH] Fixed #25400 -- Fixed regression in nonexistent features on gis backends. --- django/contrib/gis/db/backends/base/features.py | 5 ++--- tests/backends/test_features.py | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/backends/test_features.py diff --git a/django/contrib/gis/db/backends/base/features.py b/django/contrib/gis/db/backends/base/features.py index 779ff23689..14eea12721 100644 --- a/django/contrib/gis/db/backends/base/features.py +++ b/django/contrib/gis/db/backends/base/features.py @@ -98,9 +98,8 @@ class BaseSpatialFeatures(object): m = re.match(r'has_(\w*)_function$', name) if m: func_name = m.group(1) - if func_name not in self.connection.ops.unsupported_functions: - return True - return False + return func_name not in self.connection.ops.unsupported_functions + raise AttributeError def has_ops_method(self, method): return getattr(self.connection.ops, method, False) diff --git a/tests/backends/test_features.py b/tests/backends/test_features.py new file mode 100644 index 0000000000..831a0002a3 --- /dev/null +++ b/tests/backends/test_features.py @@ -0,0 +1,8 @@ +from django.db import connection +from django.test import TestCase + + +class TestDatabaseFeatures(TestCase): + + def test_nonexistent_feature(self): + self.assertFalse(hasattr(connection.features, 'nonexistent'))