remove references to nose
This commit is contained in:
parent
bc0c55e49a
commit
799cdafae6
@ -54,7 +54,7 @@ General Guidelines
|
|||||||
should adapt to the breaking change in docs/upgrade.rst.
|
should adapt to the breaking change in docs/upgrade.rst.
|
||||||
- Write inline documentation for new classes and methods.
|
- Write inline documentation for new classes and methods.
|
||||||
- Write tests and make sure they pass (make sure you have a mongod
|
- Write tests and make sure they pass (make sure you have a mongod
|
||||||
running on the default port, then execute ``python setup.py nosetests``
|
running on the default port, then execute ``python setup.py test``
|
||||||
from the cmd line to run the test suite).
|
from the cmd line to run the test suite).
|
||||||
- Ensure tests pass on all supported Python, PyMongo, and MongoDB versions.
|
- Ensure tests pass on all supported Python, PyMongo, and MongoDB versions.
|
||||||
You can test various Python and PyMongo versions locally by executing
|
You can test various Python and PyMongo versions locally by executing
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
nose
|
|
||||||
pymongo>=3.4
|
pymongo>=3.4
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
Sphinx==1.5.5
|
Sphinx==1.5.5
|
||||||
|
2
setup.py
2
setup.py
@ -120,7 +120,7 @@ extra_opts = {
|
|||||||
}
|
}
|
||||||
if sys.version_info[0] == 3:
|
if sys.version_info[0] == 3:
|
||||||
extra_opts["use_2to3"] = True
|
extra_opts["use_2to3"] = True
|
||||||
if "test" in sys.argv or "nosetests" in sys.argv:
|
if "test" in sys.argv:
|
||||||
extra_opts["packages"] = find_packages()
|
extra_opts["packages"] = find_packages()
|
||||||
extra_opts["package_data"] = {
|
extra_opts["package_data"] = {
|
||||||
"tests": ["fields/mongoengine.png", "fields/mongodb_leaf.png"]
|
"tests": ["fields/mongoengine.png", "fields/mongodb_leaf.png"]
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
from pymongo.collation import Collation
|
from pymongo.collation import Collation
|
||||||
from pymongo.errors import OperationFailure
|
from pymongo.errors import OperationFailure
|
||||||
import pytest
|
import pytest
|
||||||
@ -251,7 +250,7 @@ class TestIndexes(unittest.TestCase):
|
|||||||
def test_explicit_geohaystack_index(self):
|
def test_explicit_geohaystack_index(self):
|
||||||
"""Ensure that geohaystack indexes work when created via meta[indexes]
|
"""Ensure that geohaystack indexes work when created via meta[indexes]
|
||||||
"""
|
"""
|
||||||
raise SkipTest(
|
pytest.skip(
|
||||||
"GeoHaystack index creation is not supported for now"
|
"GeoHaystack index creation is not supported for now"
|
||||||
"from meta, as it requires a bucketSize parameter."
|
"from meta, as it requires a bucketSize parameter."
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
from unittest import SkipTest
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -46,11 +45,6 @@ class TestEmailField(MongoDBTestCase):
|
|||||||
user.validate()
|
user.validate()
|
||||||
|
|
||||||
def test_email_field_unicode_user(self):
|
def test_email_field_unicode_user(self):
|
||||||
# Don't run this test on pypy3, which doesn't support unicode regex:
|
|
||||||
# https://bitbucket.org/pypy/pypy/issues/1821/regular-expression-doesnt-find-unicode
|
|
||||||
if sys.version_info[:2] == (3, 2):
|
|
||||||
raise SkipTest("unicode email addresses are not supported on PyPy 3")
|
|
||||||
|
|
||||||
class User(Document):
|
class User(Document):
|
||||||
email = EmailField()
|
email = EmailField()
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import datetime
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bson import DBRef, ObjectId, SON
|
from bson import DBRef, ObjectId, SON
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mongoengine import (
|
from mongoengine import (
|
||||||
@ -1239,17 +1238,17 @@ class TestField(MongoDBTestCase):
|
|||||||
a = A._from_son(SON([("fb", SON([("fc", SON([("txt", "hi")]))]))]))
|
a = A._from_son(SON([("fb", SON([("fc", SON([("txt", "hi")]))]))]))
|
||||||
assert a.b.c.txt == "hi"
|
assert a.b.c.txt == "hi"
|
||||||
|
|
||||||
|
@pytest.mark.xfail(
|
||||||
|
reason="Using a string reference in an EmbeddedDocumentField does not work if the class isnt registerd yet",
|
||||||
|
raises=NotRegistered,
|
||||||
|
)
|
||||||
def test_embedded_document_field_cant_reference_using_a_str_if_it_does_not_exist_yet(
|
def test_embedded_document_field_cant_reference_using_a_str_if_it_does_not_exist_yet(
|
||||||
self,
|
self,
|
||||||
):
|
):
|
||||||
raise SkipTest(
|
|
||||||
"Using a string reference in an EmbeddedDocumentField does not work if the class isnt registerd yet"
|
|
||||||
)
|
|
||||||
|
|
||||||
class MyDoc2(Document):
|
class MyDoc2(Document):
|
||||||
emb = EmbeddedDocumentField("MyDoc")
|
emb = EmbeddedDocumentField("MyFunkyDoc123")
|
||||||
|
|
||||||
class MyDoc(EmbeddedDocument):
|
class MyFunkyDoc123(EmbeddedDocument):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
|
|
||||||
def test_embedded_document_validation(self):
|
def test_embedded_document_validation(self):
|
||||||
|
@ -5,7 +5,7 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import gridfs
|
import gridfs
|
||||||
from nose.plugins.skip import SkipTest
|
import pytest
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
@ -21,6 +21,8 @@ except ImportError:
|
|||||||
|
|
||||||
from tests.utils import MongoDBTestCase
|
from tests.utils import MongoDBTestCase
|
||||||
|
|
||||||
|
require_pil = pytest.mark.skipif(not HAS_PIL, reason="PIL not installed")
|
||||||
|
|
||||||
TEST_IMAGE_PATH = os.path.join(os.path.dirname(__file__), "mongoengine.png")
|
TEST_IMAGE_PATH = os.path.join(os.path.dirname(__file__), "mongoengine.png")
|
||||||
TEST_IMAGE2_PATH = os.path.join(os.path.dirname(__file__), "mongodb_leaf.png")
|
TEST_IMAGE2_PATH = os.path.join(os.path.dirname(__file__), "mongodb_leaf.png")
|
||||||
|
|
||||||
@ -377,10 +379,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
assert len(list(files)) == 0
|
assert len(list(files)) == 0
|
||||||
assert len(list(chunks)) == 0
|
assert len(list(chunks)) == 0
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_image_field(self):
|
def test_image_field(self):
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestImage(Document):
|
class TestImage(Document):
|
||||||
image = ImageField()
|
image = ImageField()
|
||||||
|
|
||||||
@ -411,10 +411,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
|
|
||||||
t.image.delete()
|
t.image.delete()
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_image_field_reassigning(self):
|
def test_image_field_reassigning(self):
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestFile(Document):
|
class TestFile(Document):
|
||||||
the_file = ImageField()
|
the_file = ImageField()
|
||||||
|
|
||||||
@ -428,10 +426,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
test_file.save()
|
test_file.save()
|
||||||
assert test_file.the_file.size == (45, 101)
|
assert test_file.the_file.size == (45, 101)
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_image_field_resize(self):
|
def test_image_field_resize(self):
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestImage(Document):
|
class TestImage(Document):
|
||||||
image = ImageField(size=(185, 37))
|
image = ImageField(size=(185, 37))
|
||||||
|
|
||||||
@ -451,10 +447,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
|
|
||||||
t.image.delete()
|
t.image.delete()
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_image_field_resize_force(self):
|
def test_image_field_resize_force(self):
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestImage(Document):
|
class TestImage(Document):
|
||||||
image = ImageField(size=(185, 37, True))
|
image = ImageField(size=(185, 37, True))
|
||||||
|
|
||||||
@ -474,10 +468,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
|
|
||||||
t.image.delete()
|
t.image.delete()
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_image_field_thumbnail(self):
|
def test_image_field_thumbnail(self):
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestImage(Document):
|
class TestImage(Document):
|
||||||
image = ImageField(thumbnail_size=(92, 18))
|
image = ImageField(thumbnail_size=(92, 18))
|
||||||
|
|
||||||
@ -546,11 +538,8 @@ class TestFileField(MongoDBTestCase):
|
|||||||
assert putfile == copy.copy(putfile)
|
assert putfile == copy.copy(putfile)
|
||||||
assert putfile == copy.deepcopy(putfile)
|
assert putfile == copy.deepcopy(putfile)
|
||||||
|
|
||||||
|
@require_pil
|
||||||
def test_get_image_by_grid_id(self):
|
def test_get_image_by_grid_id(self):
|
||||||
|
|
||||||
if not HAS_PIL:
|
|
||||||
raise SkipTest("PIL not installed")
|
|
||||||
|
|
||||||
class TestImage(Document):
|
class TestImage(Document):
|
||||||
|
|
||||||
image1 = ImageField()
|
image1 = ImageField()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from bson.tz_util import utc
|
from bson.tz_util import utc
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
import pymongo
|
import pymongo
|
||||||
|
|
||||||
from pymongo import MongoClient, ReadPreference
|
from pymongo import MongoClient, ReadPreference
|
||||||
@ -35,6 +34,18 @@ def get_tz_awareness(connection):
|
|||||||
return connection.codec_options.tz_aware
|
return connection.codec_options.tz_aware
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import mongomock
|
||||||
|
|
||||||
|
MONGOMOCK_INSTALLED = True
|
||||||
|
except ImportError:
|
||||||
|
MONGOMOCK_INSTALLED = False
|
||||||
|
|
||||||
|
require_mongomock = pytest.mark.skipif(
|
||||||
|
not MONGOMOCK_INSTALLED, reason="you need mongomock installed to run this testcase"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConnectionTest(unittest.TestCase):
|
class ConnectionTest(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -212,14 +223,10 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
non_string_db_name = ["e. g. list instead of a string"]
|
non_string_db_name = ["e. g. list instead of a string"]
|
||||||
connect(non_string_db_name)
|
connect(non_string_db_name)
|
||||||
|
|
||||||
|
@require_mongomock
|
||||||
def test_connect_in_mocking(self):
|
def test_connect_in_mocking(self):
|
||||||
"""Ensure that the connect() method works properly in mocking.
|
"""Ensure that the connect() method works properly in mocking.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
import mongomock
|
|
||||||
except ImportError:
|
|
||||||
raise SkipTest("you need mongomock installed to run this testcase")
|
|
||||||
|
|
||||||
connect("mongoenginetest", host="mongomock://localhost")
|
connect("mongoenginetest", host="mongomock://localhost")
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
assert isinstance(conn, mongomock.MongoClient)
|
assert isinstance(conn, mongomock.MongoClient)
|
||||||
@ -261,14 +268,10 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
conn = get_connection("testdb7")
|
conn = get_connection("testdb7")
|
||||||
assert isinstance(conn, mongomock.MongoClient)
|
assert isinstance(conn, mongomock.MongoClient)
|
||||||
|
|
||||||
|
@require_mongomock
|
||||||
def test_default_database_with_mocking(self):
|
def test_default_database_with_mocking(self):
|
||||||
"""Ensure that the default database is correctly set when using mongomock.
|
"""Ensure that the default database is correctly set when using mongomock.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
import mongomock
|
|
||||||
except ImportError:
|
|
||||||
raise SkipTest("you need mongomock installed to run this testcase")
|
|
||||||
|
|
||||||
disconnect_all()
|
disconnect_all()
|
||||||
|
|
||||||
class SomeDocument(Document):
|
class SomeDocument(Document):
|
||||||
@ -281,16 +284,12 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
assert conn.get_default_database().name == "mongoenginetest"
|
assert conn.get_default_database().name == "mongoenginetest"
|
||||||
assert conn.database_names()[0] == "mongoenginetest"
|
assert conn.database_names()[0] == "mongoenginetest"
|
||||||
|
|
||||||
|
@require_mongomock
|
||||||
def test_connect_with_host_list(self):
|
def test_connect_with_host_list(self):
|
||||||
"""Ensure that the connect() method works when host is a list
|
"""Ensure that the connect() method works when host is a list
|
||||||
|
|
||||||
Uses mongomock to test w/o needing multiple mongod/mongos processes
|
Uses mongomock to test w/o needing multiple mongod/mongos processes
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
import mongomock
|
|
||||||
except ImportError:
|
|
||||||
raise SkipTest("you need mongomock installed to run this testcase")
|
|
||||||
|
|
||||||
connect(host=["mongomock://localhost"])
|
connect(host=["mongomock://localhost"])
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
assert isinstance(conn, mongomock.MongoClient)
|
assert isinstance(conn, mongomock.MongoClient)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import operator
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
import pytest
|
||||||
|
|
||||||
from mongoengine import connect
|
from mongoengine import connect
|
||||||
from mongoengine.connection import disconnect_all, get_db
|
from mongoengine.connection import disconnect_all, get_db
|
||||||
@ -37,7 +36,7 @@ def get_as_pymongo(doc):
|
|||||||
def _decorated_with_ver_requirement(func, mongo_version_req, oper):
|
def _decorated_with_ver_requirement(func, mongo_version_req, oper):
|
||||||
"""Return a MongoDB version requirement decorator.
|
"""Return a MongoDB version requirement decorator.
|
||||||
|
|
||||||
The resulting decorator will raise a SkipTest exception if the current
|
The resulting decorator will skip the test if the current
|
||||||
MongoDB version doesn't match the provided version/operator.
|
MongoDB version doesn't match the provided version/operator.
|
||||||
|
|
||||||
For example, if you define a decorator like so:
|
For example, if you define a decorator like so:
|
||||||
@ -59,9 +58,8 @@ def _decorated_with_ver_requirement(func, mongo_version_req, oper):
|
|||||||
if oper(mongodb_v, mongo_version_req):
|
if oper(mongodb_v, mongo_version_req):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
raise SkipTest(
|
pretty_version = ".".join(str(n) for n in mongo_version_req)
|
||||||
"Needs MongoDB v{}+".format(".".join(str(n) for n in mongo_version_req))
|
pytest.skip("Needs MongoDB v{}+".format(pretty_version))
|
||||||
)
|
|
||||||
|
|
||||||
_inner.__name__ = func.__name__
|
_inner.__name__ = func.__name__
|
||||||
_inner.__doc__ = func.__doc__
|
_inner.__doc__ = func.__doc__
|
||||||
|
1
tox.ini
1
tox.ini
@ -5,7 +5,6 @@ envlist = {py27,py35,pypy,pypy3}-{mg34,mg36}
|
|||||||
commands =
|
commands =
|
||||||
python setup.py test {posargs}
|
python setup.py test {posargs}
|
||||||
deps =
|
deps =
|
||||||
nose
|
|
||||||
mg34: pymongo>=3.4,<3.5
|
mg34: pymongo>=3.4,<3.5
|
||||||
mg36: pymongo>=3.6,<3.7
|
mg36: pymongo>=3.6,<3.7
|
||||||
mg39: pymongo>=3.9,<4.0
|
mg39: pymongo>=3.9,<4.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user