nicer ver decorators + only test $minDistance in v3.0
This commit is contained in:
@@ -32,22 +32,35 @@ def get_mongodb_version():
|
||||
"""
|
||||
return get_connection().server_info()['versionArray']
|
||||
|
||||
|
||||
def skip_older_mongodb(f):
|
||||
"""Raise a SkipTest exception with a given message if we're working
|
||||
with MongoDB version lower than v2.6.
|
||||
def _decorated_with_ver_requirement(func, ver_tuple):
|
||||
"""Return a given function decorated with the version requirement
|
||||
for a particular MongoDB version tuple.
|
||||
"""
|
||||
def _inner(*args, **kwargs):
|
||||
mongodb_ver = get_mongodb_version()
|
||||
if mongodb_ver[0] == 2 and mongodb_ver[1] < 6:
|
||||
raise SkipTest('Need MongoDB v2.6+')
|
||||
return f(*args, **kwargs)
|
||||
if mongodb_ver >= ver_tuple:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
_inner.__name__ = f.__name__
|
||||
_inner.__doc__ = f.__doc__
|
||||
raise SkipTest('Needs MongoDB v{}+'.format(
|
||||
'.'.join([str(v) for v in ver_tuple])
|
||||
))
|
||||
|
||||
_inner.__name__ = func.__name__
|
||||
_inner.__doc__ = func.__doc__
|
||||
|
||||
return _inner
|
||||
|
||||
def needs_mongodb_v26(func):
|
||||
"""Raise a SkipTest exception if we're working with MongoDB version
|
||||
lower than v2.6.
|
||||
"""
|
||||
return _decorated_with_ver_requirement(func, (2, 6))
|
||||
|
||||
def needs_mongodb_v3(func):
|
||||
"""Raise a SkipTest exception if we're working with MongoDB version
|
||||
lower than v3.0.
|
||||
"""
|
||||
return _decorated_with_ver_requirement(func, (3, 0))
|
||||
|
||||
def skip_pymongo3(f):
|
||||
"""Raise a SkipTest exception if we're running a test against
|
||||
|
||||
Reference in New Issue
Block a user