summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-14 13:19:14 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-14 13:19:18 +0200
commite48fb600f40e3d3f9e3b13f70a2196a53c64d4ec (patch)
treea20a610ea47d1d0dac6aff6edf3b82f6df031114 /tests
parent676e02fd916a4e41a6080d29ef8f89925c499f35 (diff)
downloadfactory-boy-e48fb600f40e3d3f9e3b13f70a2196a53c64d4ec.tar
factory-boy-e48fb600f40e3d3f9e3b13f70a2196a53c64d4ec.tar.gz
Use temporary mongo databases for tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_mongoengine.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_mongoengine.py b/tests/test_mongoengine.py
index e078aed..c69138f 100644
--- a/tests/test_mongoengine.py
+++ b/tests/test_mongoengine.py
@@ -22,6 +22,7 @@
"""Tests for factory_boy/SQLAlchemy interactions."""
import factory
+import os
from .compat import unittest
@@ -46,6 +47,18 @@ if mongoengine:
@unittest.skipIf(mongoengine is None, "mongoengine not installed.")
class MongoEngineTestCase(unittest.TestCase):
+ db_name = os.environ.get('MONGO_DATABASE', 'factory_boy_test')
+ db_host = os.environ.get('MONGO_HOST', 'localhost')
+ db_port = os.environ.get('MONGO_PORT', '27017')
+
+ @classmethod
+ def setUpClass(cls):
+ cls.db = mongoengine.connect(cls.db_name, host=cls.db_host, port=cls.db_port)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.db.drop_database(cls.db_name)
+
def setUp(self):
mongoengine.connect('factory_boy_test')