From 30e386f645ce45c341d4e9a0aec1b6477edca8ed Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Wed, 13 May 2020 10:12:08 -0400 Subject: [PATCH] test_rtutil: Implement our own nullcontext. contextlib.nullcontext does not exist in Python 3.6. --- tests/test_rtutil.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_rtutil.py b/tests/test_rtutil.py index 7c285d0..e51c23c 100644 --- a/tests/test_rtutil.py +++ b/tests/test_rtutil.py @@ -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)