X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dc08f17cc3c90714efafb11e38e27ca8ea1b5f5b..ba34a22d9918ae97306472c04701e69090821c82:/sdk/python/tests/arvados_testutil.py diff --git a/sdk/python/tests/arvados_testutil.py b/sdk/python/tests/arvados_testutil.py index d9b3ca86c4..0035659796 100644 --- a/sdk/python/tests/arvados_testutil.py +++ b/sdk/python/tests/arvados_testutil.py @@ -280,3 +280,30 @@ if sys.version_info < (3, 0): return self.assertNotRegexpMatches(*args, **kwargs) unittest.TestCase.assertRegex = assertRegex unittest.TestCase.assertNotRegex = assertNotRegex + +def binary_compare(a, b): + if len(a) != len(b): + return False + for i in range(0, len(a)): + if a[i] != b[i]: + return False + return True + +def make_block_cache(disk_cache): + if disk_cache: + disk_cache_dir = os.path.join(os.path.expanduser("~"), ".cache", "arvados", "keep") + shutil.rmtree(disk_cache_dir, ignore_errors=True) + block_cache = arvados.keep.KeepBlockCache(disk_cache=disk_cache) + return block_cache + + +class DiskCacheBase: + def make_block_cache(self, disk_cache): + self.disk_cache_dir = tempfile.mkdtemp() if disk_cache else None + block_cache = arvados.keep.KeepBlockCache(disk_cache=disk_cache, + disk_cache_dir=self.disk_cache_dir) + return block_cache + + def tearDown(self): + if self.disk_cache_dir: + shutil.rmtree(self.disk_cache_dir)