mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 09:58:50 +08:00
7.0 became 6.3, so change API versions accordingly
This commit is contained in:
parent
7b87cc3f88
commit
ffc36dcf45
@ -253,9 +253,9 @@ def transactional(*tr_args, **tr_kwargs):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
# We can't throw this from the decorator, as when a user runs
|
||||
# >>> import fdb ; fdb.api_version(700)
|
||||
# >>> import fdb ; fdb.api_version(630)
|
||||
# the code above uses @transactional before the API version is set
|
||||
if fdb.get_api_version() >= 700 and inspect.isgeneratorfunction(func):
|
||||
if fdb.get_api_version() >= 630 and inspect.isgeneratorfunction(func):
|
||||
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
||||
|
||||
if isinstance(args[index], TransactionRead):
|
||||
@ -273,7 +273,7 @@ def transactional(*tr_args, **tr_kwargs):
|
||||
ret = None
|
||||
try:
|
||||
ret = func(*largs, **kwargs)
|
||||
if fdb.get_api_version() >= 700 and inspect.isgenerator(ret):
|
||||
if fdb.get_api_version() >= 630 and inspect.isgenerator(ret):
|
||||
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
||||
tr.commit().wait()
|
||||
committed = True
|
||||
|
@ -132,9 +132,9 @@ def test_fdb_transactional_generator(db):
|
||||
@fdb.transactional
|
||||
def function_that_yields(tr):
|
||||
yield 0
|
||||
assert fdb.get_api_version() < 700, "Pre-7.0, a decorators may wrap a function that yield"
|
||||
assert fdb.get_api_version() < 630, "Pre-6.3, a decorators may wrap a function that yield"
|
||||
except ValueError as e:
|
||||
assert fdb.get_api_version() >= 700, "Post-7.0, a decorator should throw if wrapped function yields"
|
||||
assert fdb.get_api_version() >= 630, "Post-6.3, a decorator should throw if wrapped function yields"
|
||||
|
||||
|
||||
def test_fdb_transactional_returns_generator(db):
|
||||
@ -145,9 +145,9 @@ def test_fdb_transactional_returns_generator(db):
|
||||
def function_that_returns(tr):
|
||||
return function_that_yields(tr)
|
||||
function_that_returns()
|
||||
assert fdb.get_api_version() < 700, "Pre-7.0, returning a generator is allowed"
|
||||
assert fdb.get_api_version() < 630, "Pre-6.3, returning a generator is allowed"
|
||||
except ValueError as e:
|
||||
assert fdb.get_api_version() >= 700, "Post-7.0, returning a generator should throw"
|
||||
assert fdb.get_api_version() >= 630, "Post-6.3, returning a generator should throw"
|
||||
|
||||
|
||||
def test_db_options(db):
|
||||
|
Loading…
x
Reference in New Issue
Block a user