Best Python code snippet using avocado_python
tests.py
Source:tests.py  
1from django.urls import reverse2from django.test import TestCase3from app1.views import encodeId, decodeCryptedId, gray, mosaic4class TestIndex(TestCase):5    def test_get(self):6        res = self.client.get(reverse('index'))7        self.assertTemplateUsed(res, 'app1/index.html')8    def test_post(self):9        pass10class TestProcess(TestCase):11    def test_get(self):12        pass13    def test_post(self):14        pass15class TestGray(TestCase):16    def test_grayed(self):17        test_input_url = 'https://storage.googleapis.com/imageapp_ryopenguin/documents/test.jpg?Expires=1584349899&GoogleAccessId=imageapp%40ryopenguin-9f2e7.iam.gserviceaccount.com&Signature=JJ2Ki1fXatVhEn7kOy5ZGFJenKoonfJ8NJS08y%2BlxnxVhNA80ndu42ZGgSNkthqMKqZqp5UjQcSOsbxApIEpxSQbOirEGmTNskeO2WmRg9Cm4KD%2BhzKHm7YNvMFS1TJOAXFUwgZXwUsOatleVOx7FAe5caPAFnvT6qUN0B6unGXZG%2F%2BtiRBfzO182Sf41aTqj5A6h24S%2FIvt5dKbfecnvspmpLY2hVwDvyLjOtDUVDFOuVmtb8eqr3eul8RNOMI4iFm9q23SiK8mLoYHNbrDKvk8SMHwgbVxgCSGw%2F7hsMPljSzST8LrwexH%2FB6mnCeRkavEKJJUUnB5QASSkKLPAw%3D%3D'18        test_output_pass = 'processed/test_processed.jpg'19        self.assertEqual(gray(test_input_url), test_output_pass)20    def test_error(self):21        pass22class TestMosaic(TestCase):23    def test_mosaiced(self):24        test_input_url = 'https://storage.googleapis.com/imageapp_ryopenguin/documents/test.jpg?Expires=1584349899&GoogleAccessId=imageapp%40ryopenguin-9f2e7.iam.gserviceaccount.com&Signature=JJ2Ki1fXatVhEn7kOy5ZGFJenKoonfJ8NJS08y%2BlxnxVhNA80ndu42ZGgSNkthqMKqZqp5UjQcSOsbxApIEpxSQbOirEGmTNskeO2WmRg9Cm4KD%2BhzKHm7YNvMFS1TJOAXFUwgZXwUsOatleVOx7FAe5caPAFnvT6qUN0B6unGXZG%2F%2BtiRBfzO182Sf41aTqj5A6h24S%2FIvt5dKbfecnvspmpLY2hVwDvyLjOtDUVDFOuVmtb8eqr3eul8RNOMI4iFm9q23SiK8mLoYHNbrDKvk8SMHwgbVxgCSGw%2F7hsMPljSzST8LrwexH%2FB6mnCeRkavEKJJUUnB5QASSkKLPAw%3D%3D'25        test_output_pass = 'processed/test_processed.jpg'26        self.assertEqual(mosaic(test_input_url), test_output_pass)27    def test_error(self):28        pass29class TestEncodeId(TestCase):30    def test_encode(self):31        # id = 132        randomized1 = 'MTdmNWRhZTBmNWI3NzJhZGJlOWIyMTJmZDA3YTZiZDNh'33        # id = 10034        randomized100 = 'MTAwN2Y1ZGFlMGY1Yjc3MmFkYmU5YjIxMmZkMDdhNmJkM2E='35        self.assertEqual(encodeId(1), randomized1)36        self.assertEqual(encodeId(100), randomized100)37class TestDecodeCryptedId(TestCase):38    def test_decode(self):39        # id = 140        randomized1 = 'MTdmNWRhZTBmNWI3NzJhZGJlOWIyMTJmZDA3YTZiZDNh'41        # id = 10042        randomized100 = 'MTAwN2Y1ZGFlMGY1Yjc3MmFkYmU5YjIxMmZkMDdhNmJkM2E='43        self.assertEqual(decodeCryptedId(randomized1), 1)44        self.assertEqual(decodeCryptedId(randomized100), 100)45class TestAbout(TestCase):46    def test_get(self):47        res = self.client.get(reverse('about'))48        self.assertTemplateUsed(res, 'app1/about.html')49class TestExample(TestCase):50    def test_get(self):51        res = self.client.get(reverse('example'))...test_basic_mochitest_plain.py
Source:test_basic_mochitest_plain.py  
...21    )22    for line in lines:23        parser.parse_single_line(json.dumps(line))24    return parser.evaluate_parser(status)25def test_output_pass(runtests):26    status, lines = runtests('test_pass.html')27    assert status == 028    tbpl_status, log_level = get_mozharness_status(lines, status)29    assert tbpl_status == TBPL_SUCCESS30    assert log_level == WARNING31    lines = filter_action('test_status', lines)32    assert len(lines) == 133    assert lines[0]['status'] == 'PASS'34def test_output_fail(runtests):35    from runtests import build_obj36    status, lines = runtests('test_fail.html')37    assert status == 138    tbpl_status, log_level = get_mozharness_status(lines, status)39    assert tbpl_status == TBPL_WARNING...test_reftest_output.py
Source:test_reftest_output.py  
...6from moztest.selftest.output import get_mozharness_status, filter_action7from mozharness.base.log import INFO, WARNING8from mozharness.mozilla.buildbot import TBPL_SUCCESS, TBPL_WARNING9get_mozharness_status = partial(get_mozharness_status, 'reftest')10def test_output_pass(runtests):11    status, lines = runtests('reftest-pass.list')12    assert status == 013    tbpl_status, log_level = get_mozharness_status(lines, status)14    assert tbpl_status == TBPL_SUCCESS15    assert log_level in (INFO, WARNING)16    test_end = filter_action('test_end', lines)17    assert len(test_end) == 318    assert all(t['status'] == 'PASS' for t in test_end)19def test_output_fail(runtests):20    status, lines = runtests('reftest-fail.list')21    assert status == 022    tbpl_status, log_level = get_mozharness_status(lines, status)23    assert tbpl_status == TBPL_WARNING24    assert log_level == WARNING...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!!
