def copy_test(self, test_srcdir): logger.info('{}: Start copying test to container'.format( self._container.short_id)) tar_stream = utils.create_tarfile(test_srcdir) # we have a tar archive now - copy to container if self._container.put_archive(self.test_destdir, tar_stream): logger.info('{}: Copied test to {}'.format( self._container.short_id, self.test_destdir)) else: logger.error('{}: Failed to copy test archive to ' 'container'.format(self._container.short_id))
def test_create_tarfile(self): with tempfile.TemporaryDirectory() as td: pathlib.Path(os.path.join(td, "file1.txt")).touch() tar_stream = utils.create_tarfile(td) t = tarfile.open(fileobj=tar_stream) assert 'file1.txt' in [m.name for m in t.getmembers()]