diff --git a/.gitignore b/.gitignore index 0300bc77..2771eb03 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ env/ .project .pydevproject tests/bugfix.py +htmlcov/ \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..23453407 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[aliases] +# python2.7 has upgraded unittest and it is no longer compatible with some +# of our tests, so we run all through nose +test = nosetests + +[nosetests] +verbosity = 2 +detailed-errors = 1 +with-coverage = 1 +#cover-html = 1 +#cover-html-dir = ../htmlcov +cover-package = mongoengine +cover-erase = 1 +where = tests +tests = bugfix, connection, dereference, django_tests, document, dynamic_document, fields, queryset, replicaset_connection, signals \ No newline at end of file diff --git a/setup.py b/setup.py index d92c4910..55f1418d 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,6 @@ setup(name='mongoengine', platforms=['any'], classifiers=CLASSIFIERS, install_requires=['pymongo'], - test_suite='tests', - tests_require=['blinker', 'django>=1.3', 'PIL'] + # use python setup.py nosetests to test + setup_requires=['nose', 'coverage', 'blinker', 'django>=1.3', 'PIL'] ) diff --git a/tests/connection.py b/tests/connection.py index 91bba55e..cd03df0b 100644 --- a/tests/connection.py +++ b/tests/connection.py @@ -1,8 +1,11 @@ -import unittest +import datetime import pymongo +import unittest import mongoengine.connection +from bson.tz_util import utc + from mongoengine import * from mongoengine.connection import get_db, get_connection, ConnectionError @@ -70,11 +73,26 @@ class ConnectionTest(unittest.TestCase): """ connect('mongoenginetest', alias='t1', tz_aware=True) conn = get_connection('t1') + self.assertTrue(conn.tz_aware) - + connect('mongoenginetest2', alias='t2') conn = get_connection('t2') self.assertFalse(conn.tz_aware) + def test_datetime(self): + connect('mongoenginetest', tz_aware=True) + d = datetime.datetime(2010, 5, 5, tzinfo=utc) + + class DateDoc(Document): + the_date = DateTimeField(required=True) + + DateDoc.drop_collection() + DateDoc(the_date=d).save() + + date_doc = DateDoc.objects.first() + self.assertEqual(d, date_doc.the_date) + + if __name__ == '__main__': unittest.main() diff --git a/tests/document.py b/tests/document.py index 055f980b..48eec360 100644 --- a/tests/document.py +++ b/tests/document.py @@ -6,7 +6,7 @@ import warnings from datetime import datetime -from fixtures import Base, Mixin, PickleEmbedded, PickleTest +from tests.fixtures import Base, Mixin, PickleEmbedded, PickleTest from mongoengine import * from mongoengine.base import NotRegistered, InvalidDocumentError