test_rtutil: Implement our own nullcontext.
contextlib.nullcontext does not exist in Python 3.6.
This commit is contained in:
parent
031b660cc6
commit
30e386f645
1 changed files with 5 additions and 1 deletions
|
@ -55,11 +55,15 @@ def new_client():
|
|||
TICKET_DATA = testutil.RTClient.TICKET_DATA.copy()
|
||||
return RTClient()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def nullcontext(thing):
|
||||
yield thing
|
||||
|
||||
def new_cache(database=':memory:'):
|
||||
db = rtutil.RTLinkCache.setup(database)
|
||||
if db is None:
|
||||
print("NOTE: did not set up database cache at {}".format(database))
|
||||
return contextlib.nullcontext(db)
|
||||
return nullcontext(db)
|
||||
else:
|
||||
return contextlib.closing(db)
|
||||
|
||||
|
|
Loading…
Reference in a new issue