diff --git a/tests/test_mongoengine.py b/tests/test_mongoengine.py index aeeb80fa..b39c6b3f 100644 --- a/tests/test_mongoengine.py +++ b/tests/test_mongoengine.py @@ -59,12 +59,12 @@ def setUpClass(cls, **kwargs): **kwargs, ) - @classmethod - def tearDownClass(cls): - cls.db.drop_database(cls.db_name) - mongoengine.connection.disconnect() - PersonFactory.reset_sequence() - AddressFactory.reset_sequence() + def cleanup(): + cls.db.drop_database(cls.db_name) + mongoengine.connection.disconnect() + PersonFactory.reset_sequence() + AddressFactory.reset_sequence() + cls.addClassCleanup(cleanup) def test_build(self): std = PersonFactory.build()