rename all test files so that they are prefixed by test_{orginal_filename}.py

This commit is contained in:
Bastien Gérard
2019-08-28 16:01:44 +03:00
parent 99a58d5c91
commit ddececbfea
21 changed files with 90 additions and 155 deletions

View File

@@ -1,3 +0,0 @@
from .fields import *
from .file_tests import *
from .geo import *

View File

@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
import uuid
from bson import Binary
from nose.plugins.skip import SkipTest
import six
from bson import Binary
from mongoengine import *
from tests.utils import MongoDBTestCase
@@ -77,8 +76,6 @@ class TestBinaryField(MongoDBTestCase):
self.assertEqual(0, Attachment.objects.count())
def test_primary_filter_by_binary_pk_as_str(self):
raise SkipTest("Querying by id as string is not currently supported")
class Attachment(Document):
id = BinaryField(primary_key=True)

View File

@@ -2,39 +2,38 @@
import datetime
import unittest
from bson import DBRef, ObjectId, SON
from nose.plugins.skip import SkipTest
from bson import DBRef, ObjectId, SON
from mongoengine import (
Document,
StringField,
IntField,
DateTimeField,
DateField,
ValidationError,
BooleanField,
ComplexDateTimeField,
FloatField,
ListField,
ReferenceField,
DateField,
DateTimeField,
DictField,
Document,
DoesNotExist,
DynamicDocument,
DynamicField,
EmbeddedDocument,
EmbeddedDocumentField,
GenericReferenceField,
DoesNotExist,
NotRegistered,
OperationError,
DynamicField,
FieldDoesNotExist,
EmbeddedDocumentListField,
MultipleObjectsReturned,
NotUniqueError,
BooleanField,
ObjectIdField,
SortedListField,
FieldDoesNotExist,
FloatField,
GenericLazyReferenceField,
GenericReferenceField,
IntField,
LazyReferenceField,
DynamicDocument,
ListField,
MultipleObjectsReturned,
NotRegistered,
NotUniqueError,
ObjectIdField,
OperationError,
ReferenceField,
SortedListField,
StringField,
ValidationError,
)
from mongoengine.base import BaseField, EmbeddedDocumentList, _document_registry
from mongoengine.errors import DeprecatedError
@@ -42,7 +41,7 @@ from mongoengine.errors import DeprecatedError
from tests.utils import MongoDBTestCase
class FieldTest(MongoDBTestCase):
class TestField(MongoDBTestCase):
def test_default_values_nothing_set(self):
"""Ensure that default field values are used when creating
a document.
@@ -343,7 +342,7 @@ class FieldTest(MongoDBTestCase):
doc.save()
# Unset all the fields
obj = HandleNoneFields._get_collection().update(
HandleNoneFields._get_collection().update(
{"_id": doc.id},
{"$unset": {"str_fld": 1, "int_fld": 1, "flt_fld": 1, "comp_dt_fld": 1}},
)
@@ -416,13 +415,13 @@ class FieldTest(MongoDBTestCase):
# name starting with $
with self.assertRaises(ValueError):
class User(Document):
class UserX1(Document):
name = StringField(db_field="$name")
# name containing a null character
with self.assertRaises(ValueError):
class User(Document):
class UserX2(Document):
name = StringField(db_field="name\0")
def test_list_validation(self):
@@ -2267,7 +2266,7 @@ class FieldTest(MongoDBTestCase):
Doc(bar="test")
class EmbeddedDocumentListFieldTestCase(MongoDBTestCase):
class TestEmbeddedDocumentListField(MongoDBTestCase):
def setUp(self):
"""
Create two BlogPost entries in the database, each with
@@ -2320,7 +2319,7 @@ class EmbeddedDocumentListFieldTestCase(MongoDBTestCase):
# Test with a Document
post = self.BlogPost(comments=Title(content="garbage"))
with self.assertRaises(ValidationError) as e:
with self.assertRaises(ValidationError):
post.validate()
self.assertIn("'comments'", str(ctx_err.exception))
self.assertIn(

View File

@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
import copy
import os
import unittest
import tempfile
import unittest
import gridfs
from nose.plugins.skip import SkipTest
import six
from nose.plugins.skip import SkipTest
from mongoengine import *
from mongoengine.connection import get_db
from mongoengine.python_support import StringIO
@@ -35,7 +35,7 @@ def get_file(path):
return bytes_io
class FileTest(MongoDBTestCase):
class TestFileField(MongoDBTestCase):
def tearDown(self):
self.db.drop_collection("fs.files")
self.db.drop_collection("fs.chunks")

View File

@@ -2,16 +2,10 @@
import unittest
from mongoengine import *
from mongoengine.connection import get_db
__all__ = ("GeoFieldTest",)
from tests.utils import MongoDBTestCase
class GeoFieldTest(unittest.TestCase):
def setUp(self):
connect(db="mongoenginetest")
self.db = get_db()
class TestGeoField(MongoDBTestCase):
def _test_for_expected_error(self, Cls, loc, expected):
try:
Cls(loc=loc).validate()