Best Python code snippet using avocado_python
test_test.py
Source: test_test.py
...20 self.skipTest('dummy skip test')21 def setUp(self):22 prefix = temp_dir_prefix(__name__, self, 'setUp')23 self.tmpdir = tempfile.TemporaryDirectory(prefix=prefix)24 def _get_fake_filename_test(self, name):25 class FakeFilename(test.Test):26 @property27 def filename(self):28 return name29 def test(self):30 pass31 tst_id = TestID("test", name=name)32 return FakeFilename("test", tst_id, base_logdir=self.tmpdir.name)33 def tearDown(self):34 self.tmpdir.cleanup()35 def test_ugly_name(self):36 def run(name, path_name):37 """ Initialize test and check the dirs were created """38 tst = self.DummyTest("test", TestID(1, name),39 base_logdir=self.tmpdir.name)40 self.assertEqual(os.path.basename(tst.logdir), path_name)41 self.assertTrue(os.path.exists(tst.logdir))42 self.assertEqual(os.path.dirname(os.path.dirname(tst.logdir)),43 self.tmpdir.name)44 run("/absolute/path", "1-_absolute_path")45 run("./relative/path", "1-._relative_path")46 run("../../multi_level/relative/path",47 "1-.._.._multi_level_relative_path")48 # Greek word 'kosme'49 run("\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5",50 "1-\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5")51 # Particularly problematic noncharacters in 16-bit applications52 name = ("\xb7\x95\xef\xb7\x96\xef\xb7\x97\xef\xb7\x98\xef\xb7\x99"53 "\xef\xb7\x9a\xef\xb7\x9b\xef\xb7\x9c\xef\xb7\x9d\xef\xb7"54 "\x9e\xef\xb7\x9f\xef\xb7\xa0\xef\xb7\xa1\xef\xb7\xa2\xef"55 "\xb7\xa3\xef\xb7\xa4\xef\xb7\xa5\xef\xb7\xa6\xef\xb7\xa7"56 "\xef\xb7\xa8\xef\xb7\xa9\xef\xb7\xaa\xef\xb7\xab\xef\xb7"57 "\xac\xef\xb7\xad\xef\xb7\xae\xef\xb7\xaf")58 run(name, "1-" + name)59 def test_long_name(self):60 def check(uid, name, variant, exp_logdir):61 tst = self.DummyTest("test", TestID(uid, name, variant),62 base_logdir=self.tmpdir.name)63 self.assertEqual(os.path.basename(tst.logdir), exp_logdir)64 return tst65 # Everything fits66 check(1, "a" * 253, None, "1-" + ("a" * 253))67 check(2, "a" * 251, {"variant_id": 1}, "2-" + ("a" * 251) + "_1")68 check(99, "a" * 249, {"variant_id": 88}, "99-" + ("a" * 249) + "_88")69 # Shrink name70 check(3, "a" * 252, {"variant_id": 1}, "3-" + ('a' * 251) + "_1")71 # Shrink variant72 check("a" * 253, "whatever", {"variant_id": 99}, "a" * 253 + "_9")73 check("a" * 254, "whatever", {"variant_id": 99}, "a" * 254 + "_")74 # No variant75 tst = check("a" * 255, "whatever", {"variant_id": "whatever-else"},76 "a" * 255)77 # Impossible to store (uid does not fit78 self.assertRaises(RuntimeError, check, "a" * 256, "whatever",79 {"variant_id": "else"}, None)80 self.assertEqual(os.path.basename(tst.workdir),81 os.path.basename(tst.logdir))82 def test_data_dir(self):83 """84 Checks `get_data()` won't report fs-unfriendly data dir name85 """86 max_length_name = os.path.join(self.tmpdir.name, "a" * 250)87 tst = self._get_fake_filename_test(max_length_name)88 self.assertEqual(os.path.join(self.tmpdir.name, max_length_name + ".data"),89 tst.get_data('', 'file', False))90 def test_no_data_dir(self):91 """92 Tests that with a filename too long, no datadir is possible93 """94 above_limit_name = os.path.join(self.tmpdir.name, "a" * 251)95 tst = self._get_fake_filename_test(above_limit_name)96 self.assertFalse(tst.get_data('', 'file', False))97 tst._record_reference('stdout', 'stdout.expected')98 tst._record_reference('stderr', 'stderr.expected')99 tst._record_reference('output', 'output.expected')100 def test_all_dirs_exists_no_hang(self):101 with unittest.mock.patch('os.path.exists', return_value=True):102 self.assertRaises(exceptions.TestSetupFail, self.DummyTest, "test",103 TestID(1, "name"), base_logdir=self.tmpdir.name)104 def test_try_override_test_variable(self):105 dummy_test = self.DummyTest(base_logdir=self.tmpdir.name)106 self.assertRaises(AttributeError, setattr, dummy_test, "name", "whatever")107 self.assertRaises(AttributeError, setattr, dummy_test, "status", "whatever")108 def test_check_reference_success(self):109 '''...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!