def test_create_from_file_returned_path(self, tmpdir): src_file = MockEmbFile(path='path/to/file.txt') # default out_dir and out_filename out_path = MockEmbFile.create_from_file(src_file, compression='gz') assert out_path == Path('path/to/file.mock.gz') # custom out_dir and filename out_path = MockEmbFile.create_from_file( src_file, out_dir='out/dir/', out_filename='out_filename.mock') assert out_path == Path('out/dir/out_filename.mock')
def test_create_from_file_returned_path_with_compressed_source_file( self, tmpdir): # We need to create a real compressed file because EmbFile decompresses it path = tmpdir / 'file.txt.gz' with gzip.open(path, 'wt') as f: f.write('ciao') compressed_src_file = MockEmbFile(path=path) # default out_dir and out_filename + source file is compressed out_path = MockEmbFile.create_from_file(compressed_src_file, compression='bz2') assert out_path == Path(tmpdir / 'file.mock.bz2') # non-default filename arg out_path = MockEmbFile.create_from_file(compressed_src_file, out_filename='changed', compression='bz2') assert out_path == Path(tmpdir / 'changed')