def check_compress_file(ext, annex, path, name): # we base the archive name on the filename, in order to also # be able to properly test compressors where the corresponding # archive format has no capability of storing a filename # (i.e. where the archive name itself determines the filename # of the decompressed file, like .xz) archive = op.join(name, _filename + ext) compress_files([_filename], archive, path=path) assert_true(op.exists(archive)) if annex: # It should work even when file is annexed and is a symlink to the # key from datalad.support.annexrepo import AnnexRepo repo = AnnexRepo(path, init=True) repo.add(_filename) repo.commit(files=[_filename], msg="commit") dir_extracted = name + "_extracted" try: decompress_file(archive, dir_extracted) except MissingExternalDependency as exc: raise SkipTest(exc_str(exc)) _filepath = op.join(dir_extracted, _filename) ok_file_has_content(_filepath, 'content')
def check_compress_dir(ext, path, name): archive = name + ext compress_files([os.path.basename(path)], archive, path=os.path.dirname(path)) assert_true(op.exists(archive)) name_extracted = name + "_extracted" decompress_file(archive, name_extracted, leading_directories='strip') assert_true(op.exists(op.join(name_extracted, 'empty'))) assert_true(op.exists(op.join(name_extracted, 'd1', 'd2', 'f1')))