From e48fb600f40e3d3f9e3b13f70a2196a53c64d4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Sat, 14 Sep 2013 13:19:14 +0200 Subject: Use temporary mongo databases for tests. --- tests/test_mongoengine.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_mongoengine.py') 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') -- cgit v1.2.3