def check_relative_path_file(self): """Check compress command on a relative path to a file""" filename = self._make_random_file(self.tempdir) os.chdir(self.tempdir) filename = os.path.basename(filename) assert len(filename.split(os.path.sep)) == 1 # compress it! os.system(_compress_cmd(filename)) self._validate_compressed(filename)
def check_abs_path_file(self): """Check compress command on an absolute path to a file""" filename = self._make_random_file(self.tempdir) abspath_filename = os.path.abspath(filename) # since we're using absolute path to file, we should be able to run the compress command from anywhere tempdir2 = tempfile.mkdtemp(dir=self.tempdir) os.chdir(tempdir2) os.system(_compress_cmd(abspath_filename)) self._validate_compressed(abspath_filename)
def check_relative_path_dir(self): """Validate tarball compression of a directory""" dirname = tempfile.mkdtemp(dir=self.tempdir) self._make_files(dirname) dirname = os.path.basename(dirname) assert len(dirname.split(os.path.sep)) == 1 # compress it! with in_dir(self.tempdir): os.system(_compress_cmd(dirname)) self._validate_compressed(dirname)
def check_abs_path_file(self): """Check compress command on an absolute path to a file""" with in_temp_dir() as dir1: filename = self._make_random_file(self.tempdir) abspath_filename = os.path.abspath(filename) # since we're using absolute path to file, we should be able to run the compress command from anywhere with in_temp_dir() as dir2: assert dir1 != dir2 os.system(_compress_cmd(abspath_filename)) self._validate_compressed(abspath_filename)
def check_abs_path_dir(self): """Validate compress command with absolute path to a directory""" dirname = tempfile.mkdtemp(dir=self.tempdir) dirname = os.path.abspath(dirname) self._make_files(dirname) # compress it! if not dirname.endswith(os.path.sep): # extra check - ensure all of this works with trailing '/' dirname += os.path.sep os.system(_compress_cmd(dirname)) self._validate_compressed(dirname)