Skip to content

Instantly share code, notes, and snippets.

@trbs
Created September 22, 2014 15:05
Show Gist options
  • Save trbs/3a0d2a1756c456d5d523 to your computer and use it in GitHub Desktop.
Save trbs/3a0d2a1756c456d5d523 to your computer and use it in GitHub Desktop.
diff --git a/runtests.py b/runtests.py
index 08c33ea..2e55864 100755
--- a/runtests.py
+++ b/runtests.py
@@ -27,9 +27,13 @@ def get_runner(settings_module):
'''
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
+ import django
from django.test.utils import get_runner
from django.conf import settings
+ if hasattr(django, 'setup'):
+ django.setup()
+
return get_runner(settings)
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index ead9a13..aa05acb 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -4,7 +4,11 @@ import datetime
from decimal import Decimal
from django.db.models import Q, F
-from django.test import TestCase, Approximate
+from django.test import TestCase
+try:
+ from django.test.utils import Approximate
+except ImportError:
+ from django.test import Approximate
from aggregate_if import Sum, Count, Avg, Max, Min
@@ -524,7 +528,7 @@ class BaseAggregateTestCase(TestCase):
vals = Author.objects.filter(pk=1).aggregate(Count("friends__id"))
self.assertEqual(vals, {"friends__id__count": 2})
- books = Book.objects.annotate(num_authors=Count("authors__name")).filter(num_authors__ge=2).order_by("pk")
+ books = Book.objects.annotate(num_authors=Count("authors__name")).filter(num_authors=2).order_by("pk")
self.assertQuerysetEqual(
books, [
"The Definitive Guide to Django: Web Development Done Right",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment