Skip to content

Commit

Permalink
Merge branch '2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Sep 3, 2020
2 parents 0d2569e + 7f2c3d4 commit ad80162
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions tests/frameworks/test_mongomock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

from ..common import TEST_DB

DEP_ERROR = 'Missing mongomock'

try:
from mongomock import MongoClient
except ImportError:
dep_error = 'Missing mongomock module'
dep_error = True
else:
dep_error = None
dep_error = False


if not dep_error: # Make sure the module is valid by importing it
Expand All @@ -26,7 +28,7 @@ def db():


# MongoMockBuilder is 100% based on PyMongoBuilder so no need for really heavy tests
@pytest.mark.skipif(dep_error is not None, reason=dep_error)
@pytest.mark.skipif(dep_error, reason=DEP_ERROR)
def test_mongomock(classroom_model):
Student = classroom_model.Student
john = Student(name='John Doe', birthday=datetime(1995, 12, 12))
Expand Down
10 changes: 6 additions & 4 deletions tests/frameworks/test_motor_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
from bson import ObjectId
import marshmallow as ma

DEP_ERROR = 'Missing motor'

# Check if the required dependancies are met to run this driver's tests
try:
from motor.motor_asyncio import AsyncIOMotorClient
from motor import version_tuple as MOTOR_VERSION
except ImportError as e:
dep_error = str(e)
except ImportError:
dep_error = True
else:
dep_error = None
dep_error = False

from ..common import BaseDBTest, TEST_DB

Expand Down Expand Up @@ -56,7 +58,7 @@ def loop():
return asyncio.get_event_loop()


@pytest.mark.skipif(dep_error is not None, reason=dep_error)
@pytest.mark.skipif(dep_error, reason=DEP_ERROR)
class TestMotorAsyncio(BaseDBTest):

def test_create(self, loop, classroom_model):
Expand Down
7 changes: 4 additions & 3 deletions tests/frameworks/test_txmongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

from ..common import BaseDBTest, TEST_DB, con

DEP_ERROR = 'Missing txmongo or pytest_twisted'

# Check if the required dependencies are met to run this driver's tests
dep_error = None
try:
import pytest_twisted
from txmongo import MongoConnection
from twisted.internet.defer import Deferred, inlineCallbacks, succeed
except ImportError:
dep_error = 'Missing txmongo or pytest_twisted'
dep_error = True

# Given the test function are generator, we must wrap them into a dummy
# function that pytest can skip
Expand All @@ -33,6 +33,7 @@ def wrapper(self):
pytest_inlineCallbacks = skip_wrapper
else:
pytest_inlineCallbacks = pytest_twisted.inlineCallbacks
dep_error = False

from umongo import (
Document, EmbeddedDocument, MixinDocument, fields, exceptions, Reference
Expand Down Expand Up @@ -64,7 +65,7 @@ def db():
return make_db()


@pytest.mark.skipif(dep_error is not None, reason=dep_error)
@pytest.mark.skipif(dep_error, reason=DEP_ERROR)
class TestTxMongo(BaseDBTest):

@pytest_inlineCallbacks
Expand Down

0 comments on commit ad80162

Please sign in to comment.