Fix MongoTestCase and add test for it
This commit is contained in:
parent
c4b3196917
commit
3e54da03e2
@ -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()
|
||||
|
@ -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__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user