# Path: tests/helpers.py
# def assert_raises_with_message(
#     exception_type, message, function, *args, **kwargs):
#     """Assert that a function raises an exception with :param message: as its
#     message.
#     """
#     try:
#         function(*args, **kwargs)
#     except exception_type as ex:
#         if str(ex) != message:
#             raise AssertionError(
#                 'Expected {0} with message of {1}, but message was {2}'
#                 .format(exception_type.__name__, repr(message), repr(str(ex))))
#         return
#     raise AssertionError('{0} not raised'.format(exception_type.__name__))


import datetime
import scalymongo.schema as mod
from dingus import Dingus, DingusTestCase, DontCare
from nose.tools import assert_raises
from scalymongo.schema import *
from tests.helpers import assert_raises_with_message
        assert_raises_with_message(
            ValidationError,
            "Position 'field' was declared to be <type 'str'>, but encountered value 1",
            validate_update_modifier, {'$set': {'field': 1}}, {'field': str})


class WhenUnsettingField(object):

    def should_not_crash(self):
        validate_update_modifier({'$unset': {'field': 1}}, {'field': int})


### $inc modifier ###


class WhenIncrementingIntField(object):

    def should_not_crash(self):
        validate_update_modifier({'$inc': {'field': 1}}, {'field': int})


class WhenIncrementingFloatField(object):

    def should_not_crash(self):
        validate_update_modifier({'$inc': {'field': .5}}, {'field': float})


class WhenIncrementingDatetimeField(object):

    def should_raise_validation_error(self):

# Path: tests/helpers.py
# def assert_raises_with_message(
#     exception_type, message, function, *args, **kwargs):
#     """Assert that a function raises an exception with :param message: as its
#     message.
#     """
#     try:
#         function(*args, **kwargs)
#     except exception_type as ex:
#         if str(ex) != message:
#             raise AssertionError(
#                 'Expected {0} with message of {1}, but message was {2}'
#                 .format(exception_type.__name__, repr(message), repr(str(ex))))
#         return
#     raise AssertionError('{0} not raised'.format(exception_type.__name__))


# Path: tests/unit/test_schema.py
import datetime
import scalymongo.schema as mod
from dingus import Dingus, DingusTestCase, DontCare
from nose.tools import assert_raises
from scalymongo.schema import *
from tests.helpers import assert_raises_with_message

        assert_raises_with_message(
            ValidationError,
            "Position 'field' was declared to be <type 'str'>, but encountered value 1",
            validate_update_modifier, {'$set': {'field': 1}}, {'field': str})


class WhenUnsettingField(object):

    def should_not_crash(self):
        validate_update_modifier({'$unset': {'field': 1}}, {'field': int})


### $inc modifier ###


class WhenIncrementingIntField(object):

    def should_not_crash(self):
        validate_update_modifier({'$inc': {'field': 1}}, {'field': int})


class WhenIncrementingFloatField(object):

    def should_not_crash(self):
        validate_update_modifier({'$inc': {'field': .5}}, {'field': float})


class WhenIncrementingDatetimeField(object):

    def should_raise_validation_error(self):

        assert_raises_with_message(