diff --git a/tests/all_warnings/__init__.py b/tests/all_warnings/__init__.py index 220b0bbf..8cbe22df 100644 --- a/tests/all_warnings/__init__.py +++ b/tests/all_warnings/__init__.py @@ -3,7 +3,8 @@ This test has been put into a module. This is because it tests warnings that only get triggered on first hit. This way we can ensure its imported into the top level and called first by the test suite. """ - +import sys +sys.path[0:0] = [""] import unittest import warnings @@ -88,3 +89,6 @@ class AllWarnings(unittest.TestCase): self.assertEqual(SyntaxWarning, warning["category"]) self.assertEqual('non_abstract_base', InheritedDocumentFailTest._get_collection_name()) + +import sys +sys.path[0:0] = [""] \ No newline at end of file diff --git a/tests/document/class_methods.py b/tests/document/class_methods.py index 8e9a8776..83e68ff8 100644 --- a/tests/document/class_methods.py +++ b/tests/document/class_methods.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import with_statement +import sys +sys.path[0:0] = [""] import unittest from mongoengine import * diff --git a/tests/document/dynamic.py b/tests/document/dynamic.py index 4848b8fa..5881cd07 100644 --- a/tests/document/dynamic.py +++ b/tests/document/dynamic.py @@ -1,6 +1,5 @@ import unittest import sys - sys.path[0:0] = [""] from mongoengine import * diff --git a/tests/document/indexes.py b/tests/document/indexes.py index c059590b..ff08ef1a 100644 --- a/tests/document/indexes.py +++ b/tests/document/indexes.py @@ -2,7 +2,6 @@ from __future__ import with_statement import unittest import sys - sys.path[0:0] = [""] import os diff --git a/tests/document/inheritance.py b/tests/document/inheritance.py index c5e1860b..3b550f1a 100644 --- a/tests/document/inheritance.py +++ b/tests/document/inheritance.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import sys +sys.path[0:0] = [""] import unittest import warnings diff --git a/tests/document/validation.py b/tests/document/validation.py index 0f67f50a..24ffed65 100644 --- a/tests/document/validation.py +++ b/tests/document/validation.py @@ -121,7 +121,7 @@ class ValidatorErrorTest(unittest.TestCase): except ValidationError, e: self.assertTrue("SubDoc:None" in e.message) self.assertEqual(e.to_dict(), { - 'e.val': 'Field is required'}) + "e": {'val': 'OK could not be converted to int'}}) Doc.drop_collection() @@ -139,7 +139,7 @@ class ValidatorErrorTest(unittest.TestCase): except ValidationError, e: self.assertTrue("Doc:test" in e.message) self.assertEqual(e.to_dict(), { - 'e.val': 'Field is required'}) + "e": {'val': 'OK could not be converted to int'}}) if __name__ == '__main__': diff --git a/tests/test_connection.py b/tests/test_connection.py index c32d231f..5b9743d6 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1,13 +1,14 @@ from __future__ import with_statement -import datetime -import pymongo +import sys +sys.path[0:0] = [""] import unittest +import datetime -import mongoengine.connection - +import pymongo from bson.tz_util import utc from mongoengine import * +import mongoengine.connection from mongoengine.connection import get_db, get_connection, ConnectionError from mongoengine.context_managers import switch_db diff --git a/tests/test_context_managers.py b/tests/test_context_managers.py index c9efe8b8..eef63bee 100644 --- a/tests/test_context_managers.py +++ b/tests/test_context_managers.py @@ -1,4 +1,6 @@ from __future__ import with_statement +import sys +sys.path[0:0] = [""] import unittest from mongoengine import * diff --git a/tests/test_dereference.py b/tests/test_dereference.py index adbc5192..4198f3c4 100644 --- a/tests/test_dereference.py +++ b/tests/test_dereference.py @@ -1,7 +1,6 @@ from __future__ import with_statement import sys sys.path[0:0] = [""] - import unittest from bson import DBRef, ObjectId diff --git a/tests/test_django.py b/tests/test_django.py index 3b0b04f8..563f4074 100644 --- a/tests/test_django.py +++ b/tests/test_django.py @@ -1,4 +1,6 @@ from __future__ import with_statement +import sys +sys.path[0:0] = [""] import unittest from nose.plugins.skip import SkipTest from mongoengine.python_support import PY3 @@ -163,3 +165,6 @@ class MongoDBSessionTest(SessionTestsMixin, unittest.TestCase): key = session.session_key session = SessionStore(key) self.assertTrue('test_expire' in session, 'Session has expired before it is expected') + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_replicaset_connection.py b/tests/test_replicaset_connection.py index 3118c5a4..d27960f7 100644 --- a/tests/test_replicaset_connection.py +++ b/tests/test_replicaset_connection.py @@ -1,3 +1,5 @@ +import sys +sys.path[0:0] = [""] import unittest import pymongo diff --git a/tests/test_signals.py b/tests/test_signals.py index 2ca820da..fc638cfc 100644 --- a/tests/test_signals.py +++ b/tests/test_signals.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import sys +sys.path[0:0] = [""] import unittest from mongoengine import * @@ -21,6 +23,7 @@ class SignalTests(unittest.TestCase): def setUp(self): connect(db='mongoenginetest') + class Author(Document): name = StringField() @@ -70,7 +73,6 @@ class SignalTests(unittest.TestCase): signal_output.append('Not loaded') self.Author = Author - class Another(Document): name = StringField() @@ -122,8 +124,8 @@ class SignalTests(unittest.TestCase): self.ExplicitId = ExplicitId self.ExplicitId.objects.delete() - # Save up the number of connected signals so that we can check at the end - # that all the signals we register get properly unregistered + # Save up the number of connected signals so that we can check at the + # end that all the signals we register get properly unregistered self.pre_signals = ( len(signals.pre_init.receivers), len(signals.post_init.receivers), @@ -192,7 +194,7 @@ class SignalTests(unittest.TestCase): """ Model saves should throw some signals. """ def create_author(): - a1 = self.Author(name='Bill Shakespeare') + self.Author(name='Bill Shakespeare') def bulk_create_author_with_load(): a1 = self.Author(name='Bill Shakespeare') @@ -216,7 +218,7 @@ class SignalTests(unittest.TestCase): ]) a1.reload() - a1.name='William Shakespeare' + a1.name = 'William Shakespeare' self.assertEqual(self.get_signal_output(a1.save), [ "pre_save signal, William Shakespeare", "post_save signal, William Shakespeare", @@ -257,3 +259,6 @@ class SignalTests(unittest.TestCase): self.assertEqual(self.get_signal_output(ei.save), ['Is created']) # second time, it must be an update self.assertEqual(self.get_signal_output(ei.save), ['Is updated']) + +if __name__ == '__main__': + unittest.main()