Best Python code snippet using avocado_python
test_archive.py
Source:test_archive.py
...33 file_path = os.path.join(root, name)34 relative_path = file_path.replace(self.decompressdir, '')35 hash_map_2[relative_path] = crypto.hash_file(file_path)36 self.assertEqual(hash_map_1, hash_map_2)37 def compress_and_check_file(self, extension):38 str_length = self.sys_random.randint(30, 50)39 fd, filename = tempfile.mkstemp(dir=self.basedir, text=True)40 os.write(fd, data_factory.generate_random_string(str_length))41 original_hash = crypto.hash_file(filename)42 dstfile = filename + extension43 archive_filename = os.path.join(self.basedir, dstfile)44 archive.compress(archive_filename, filename)45 archive.uncompress(archive_filename, self.decompressdir)46 decompress_file = os.path.join(self.decompressdir,47 os.path.basename(filename))48 decompress_hash = crypto.hash_file(decompress_file)49 self.assertEqual(original_hash, decompress_hash)50 def test_zip_dir(self):51 self.compress_and_check_dir('.zip')52 def test_zip_file(self):53 self.compress_and_check_file('.zip')54 def test_tar_dir(self):55 self.compress_and_check_dir('.tar')56 def test_tar_file(self):57 self.compress_and_check_file('.tar')58 def test_tgz_dir(self):59 self.compress_and_check_dir('.tar.gz')60 def test_tgz_file(self):61 self.compress_and_check_file('.tar.gz')62 def test_tgz_2_dir(self):63 self.compress_and_check_dir('.tgz')64 def test_tgz_2_file(self):65 self.compress_and_check_file('.tgz')66 def test_tbz2_dir(self):67 self.compress_and_check_dir('.tar.bz2')68 def test_tbz2_file(self):69 self.compress_and_check_file('.tar.bz2')70 def test_tbz2_2_dir(self):71 self.compress_and_check_dir('.tbz2')72 def test_tbz2_2_file(self):73 self.compress_and_check_file('.tbz2')74 def test_zip_extra_attrs(self):75 """76 Check that utils.archive reflects extra attrs of file like symlinks77 and file permissions.78 """79 def get_path(*args):80 """ Get path with decompressdir prefix """81 return os.path.join(self.decompressdir, *args)82 # File types83 zip_path = os.path.abspath(os.path.join(os.path.dirname(__file__),84 os.path.pardir, ".data",85 "test_archive__symlinks.zip"))86 # TODO: Handle permission correctly for all users87 # The umask is not yet handled by utils.archive, hardcode it for now...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!