Best Python code snippet using avocado_python
test_test.py
Source:test_test.py
...61 "test", TestID(uid, name, variant), base_logdir=self.tmpdir.name62 )63 self.assertEqual(os.path.basename(tst.workdir), exp_logdir)64 return tst65 max_length = path.get_max_file_name_length(self.tmpdir.name)66 # uid takes 2 chars, but still fits67 length = max_length - 268 check(1, "a" * length, None, "1-" + ("a" * length))69 # uid and variant each takes 2 chars, but still fits70 length = max_length - 471 check(2, "a" * length, {"variant_id": 1}, "2-" + ("a" * length) + "_1")72 # uid and variant each takes 3 chars, but still fits73 length = max_length - 674 check(99, "a" * length, {"variant_id": 88}, "99-" + ("a" * length) + "_88")75 # name is one char over limit, so name must shrink76 length = max_length - 377 check(3, "a" * length, {"variant_id": 1}, "3-" + ("a" * (length - 1)) + "_1")78 # Shrink variant79 length = max_length - 2...
test_astring.py
Source:test_astring.py
...99 def test_safe_path(self):100 self.assertEqual(astring.string_to_safe_path('a<>:"/\\|\\?*b'), "a__________b")101 self.assertEqual(astring.string_to_safe_path(".."), "_.")102 name = " " * 300103 max_length = path.get_max_file_name_length(name)104 self.assertEqual(len(astring.string_to_safe_path(" " * 300)), max_length)105 avocado = "\u0430\u0432\u043e\u043a\u0430\u0434\xff<>"106 self.assertEqual(astring.string_to_safe_path(avocado), f"{avocado[:-2]}__")107 def test_is_bytes(self):108 """109 Verifies what bytes means, basically that they are the same110 thing across Python 2 and 3 and can be decoded into "text"111 """112 binary = b""113 text = ""114 self.assertTrue(astring.is_bytes(binary))115 self.assertFalse(astring.is_bytes(text))116 self.assertTrue(hasattr(binary, "decode"))117 self.assertTrue(astring.is_text(binary.decode()))...
test_test_id.py
Source:test_test_id.py
...30 the Test ID, that's the only thing that will be kept.31 """32 uid = 133 name = "test"34 max_length = path.get_max_file_name_length(name)35 test_id = TestID(uid, name, no_digits=max_length)36 self.assertEqual(test_id.uid, 1)37 self.assertEqual(test_id.str_uid, f"{uid:0{max_length}d}")38 self.assertEqual(test_id.str_filesystem, f"{uid:0{max_length}d}")39 self.assertIs(test_id.variant, None)40 self.assertIs(test_id.str_variant, "")41 def test_uid_name_uid_too_large_digits(self):42 """43 Tests that when the filesystem can not cope with the size of44 the Test ID, not even the test uid, an exception will be45 raised.46 """47 name = "test"48 max_length = path.get_max_file_name_length(name)49 over_limit = max_length + 150 test_id = TestID(1, name, no_digits=over_limit)51 self.assertRaises(RuntimeError, lambda: test_id.str_filesystem)52 def test_uid_large_name(self):53 """54 Tests that when the filesystem can not cope with the size of55 the Test ID, the name will be shortened.56 """57 uid = 158 name = "test_" * 51 # 255 characters59 test_id = TestID(uid, name)60 max_length = path.get_max_file_name_length(name)61 self.assertEqual(test_id.uid, 1)62 # 2 chars are taken by the uid and dash63 max_name_length = max_length - 264 self.assertEqual(test_id.str_filesystem, f"{uid}-{name[:max_name_length]}")65 self.assertIs(test_id.variant, None)66 self.assertIs(test_id.str_variant, "")67 def test_uid_name_large_variant(self):68 """69 Tests that when the filesystem can not cope with the size of70 the Test ID, and a variant name is present, the name will be71 removed.72 """73 uid = 174 name = "test"75 variant_id = "fast_" * 51 # 255 characters76 variant = {"variant_id": variant_id}77 test_id = TestID(uid, name, variant=variant)78 max_length = path.get_max_file_name_length(name)79 # 2 chars are taken by the uid and dash80 max_name_length = max_length - 281 self.assertEqual(test_id.uid, 1)82 self.assertEqual(83 test_id.str_filesystem, f"{uid}_{variant_id[:max_name_length]}"84 )85 self.assertIs(test_id.variant, variant_id)86 self.assertEqual(test_id.str_variant, f";{variant_id}")87if __name__ == "__main__":...
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!!