Python 2.5 and 3.1 support confirmed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from __future__ import with_statement
|
||||
import unittest
|
||||
from nose.plugins.skip import SkipTest
|
||||
from mongoengine.python3_support import PY3
|
||||
from mongoengine.python_support import PY3
|
||||
from mongoengine import *
|
||||
|
||||
try:
|
||||
|
||||
@@ -43,7 +43,7 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
self.warning_list = []
|
||||
showwarning_default = warnings.showwarning
|
||||
|
||||
|
||||
def append_to_warning_list(message,category, *args):
|
||||
self.warning_list.append({"message":message, "category":category})
|
||||
|
||||
@@ -55,7 +55,7 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
class InheritedClass(SimpleBase):
|
||||
b = IntField()
|
||||
|
||||
|
||||
# restore default handling of warnings
|
||||
warnings.showwarning = showwarning_default
|
||||
|
||||
@@ -150,7 +150,7 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
def append_to_warning_list(message, category, *args):
|
||||
self.warning_list.append({'message':message, 'category':category})
|
||||
|
||||
|
||||
# add warnings to self.warning_list instead of stderr
|
||||
warnings.showwarning = append_to_warning_list
|
||||
warnings.simplefilter("always")
|
||||
@@ -209,7 +209,6 @@ class DocumentTest(unittest.TestCase):
|
||||
}
|
||||
self.assertEqual(Dog._superclasses, dog_superclasses)
|
||||
|
||||
|
||||
def test_external_superclasses(self):
|
||||
"""Ensure that the correct list of sub and super classes is assembled.
|
||||
when importing part of the model
|
||||
@@ -568,22 +567,22 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
class Drinker(Document):
|
||||
drink = GenericReferenceField()
|
||||
|
||||
|
||||
try:
|
||||
warnings.simplefilter("error")
|
||||
|
||||
|
||||
class AcloholicDrink(Drink):
|
||||
meta = {'collection': 'booze'}
|
||||
|
||||
|
||||
except SyntaxWarning, w:
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
|
||||
class AlcoholicDrink(Drink):
|
||||
meta = {'collection': 'booze'}
|
||||
|
||||
|
||||
else:
|
||||
raise AssertionError("SyntaxWarning should be triggered")
|
||||
|
||||
|
||||
warnings.resetwarnings()
|
||||
|
||||
Drink.drop_collection()
|
||||
|
||||
@@ -14,7 +14,7 @@ from nose.plugins.skip import SkipTest
|
||||
from mongoengine import *
|
||||
from mongoengine.connection import get_db
|
||||
from mongoengine.base import _document_registry, NotRegistered
|
||||
from mongoengine.python3_support import PY3, b, StringIO, bin_type
|
||||
from mongoengine.python_support import PY3, b, StringIO, bin_type
|
||||
|
||||
TEST_IMAGE_PATH = os.path.join(os.path.dirname(__file__), 'mongoengine.png')
|
||||
|
||||
@@ -383,7 +383,7 @@ class FieldTest(unittest.TestCase):
|
||||
self.assertNotEqual(log.date, d1)
|
||||
self.assertEqual(log.date, d2)
|
||||
|
||||
if not PY3:
|
||||
if not PY3:
|
||||
# Pre UTC dates microseconds below 1000 are dropped
|
||||
# This does not seem to be true in PY3
|
||||
d1 = datetime.datetime(1969, 12, 31, 23, 59, 59, 999)
|
||||
@@ -1744,7 +1744,7 @@ class FieldTest(unittest.TestCase):
|
||||
self.assertEqual(doc_b.the_file.grid_id, doc_c.the_file.grid_id)
|
||||
|
||||
# Test with default
|
||||
doc_d = GridDocument(the_file=b(''))
|
||||
doc_d = GridDocument(the_file=b(''))
|
||||
doc_d.save()
|
||||
|
||||
doc_e = GridDocument.objects.with_id(doc_d.id)
|
||||
@@ -2157,11 +2157,11 @@ class FieldTest(unittest.TestCase):
|
||||
post = Post(title='hello world')
|
||||
post.comments.append(Comment(content='hello', author=bob))
|
||||
post.comments.append(Comment(author=bob))
|
||||
|
||||
|
||||
self.assertRaises(ValidationError, post.validate)
|
||||
try:
|
||||
post.validate()
|
||||
except ValidationError, error:
|
||||
except ValidationError, error:
|
||||
# ValidationError.errors property
|
||||
self.assertTrue(hasattr(error, 'errors'))
|
||||
self.assertTrue(isinstance(error.errors, dict))
|
||||
|
||||
@@ -9,7 +9,7 @@ from bson import ObjectId
|
||||
|
||||
from mongoengine import *
|
||||
from mongoengine.connection import get_connection
|
||||
from mongoengine.python3_support import PY3
|
||||
from mongoengine.python_support import PY3
|
||||
from mongoengine.tests import query_counter
|
||||
from mongoengine.queryset import (QuerySet, QuerySetManager,
|
||||
MultipleObjectsReturned, DoesNotExist,
|
||||
@@ -1455,6 +1455,8 @@ class QuerySetTest(unittest.TestCase):
|
||||
name = StringField()
|
||||
parent = ReferenceField('self', reverse_delete_rule=CASCADE)
|
||||
|
||||
Category.drop_collection()
|
||||
|
||||
num_children = 3
|
||||
base = Category(name='Root')
|
||||
base.save()
|
||||
|
||||
Reference in New Issue
Block a user