From 0d81e7933e760f81365bd4fa58175e2ee85ceef9 Mon Sep 17 00:00:00 2001 From: Aleksey Porfirov Date: Sat, 5 Jul 2014 00:06:10 +0400 Subject: [PATCH] Prevent accessing not yet configured settings in django.MongoTestCase --- mongoengine/django/tests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mongoengine/django/tests.py b/mongoengine/django/tests.py index 1fab6fc3..c7af42a3 100644 --- a/mongoengine/django/tests.py +++ b/mongoengine/django/tests.py @@ -26,7 +26,11 @@ class MongoTestCase(TestCase): """ TestCase class that clear the collection between the tests """ - db_name = 'test_%s' % settings.MONGO_DATABASE_NAME + + @property + def db_name(self): + return 'test_%s' % settings.MONGO_DATABASE_NAME + def __init__(self, methodName='runtest'): self.db = connect(self.db_name).get_db() super(MongoTestCase, self).__init__(methodName)