Fix MongoTestCase and add test for it

This commit is contained in:
Aleksey Porfirov 2014-07-05 21:35:31 +04:00
parent c4b3196917
commit 3e54da03e2
2 changed files with 6 additions and 23 deletions

View File

@ -1,16 +1,9 @@
#coding: utf-8
from unittest import TestCase
from mongoengine import connect
from mongoengine.connection import get_db
from mongoengine.python_support import PY3
try:
from django.test import TestCase
except Exception as err:
if PY3:
from unittest import TestCase
else:
raise err
class MongoTestCase(TestCase):
@ -28,20 +21,11 @@ class MongoTestCase(TestCase):
self.db = get_db()
super(MongoTestCase, self).__init__(methodName)
def _post_teardown(self):
super(MongoTestCase, self)._post_teardown()
def dropCollections(self):
for collection in self.db.collection_names():
if collection == 'system.indexes':
continue
self.db.drop_collection(collection)
# prevent standard db init
def _databases_names(self, *args, **kwargs):
return []
def _fixture_setup(self):
pass
def _fixture_teardown(self):
pass
def tearDown(self):
self.dropCollections()

View File

@ -301,8 +301,7 @@ class MongoAuthTest(unittest.TestCase):
class MongoTestCaseTest(MongoTestCase):
def test_mongo_test_case(self):
# test __init__ and teardown in MongoTestCase
pass
self.db.dummy_collection.insert({'collection': 'will be dropped'})
if __name__ == '__main__':