Best Python code snippet using autotest_python
kernel_unittest.py
Source:kernel_unittest.py
...153 def test_constructor(self):154 self.construct_kernel()155 def test_kernelexpand1(self):156 self.construct_kernel()157 ret_val = self.kernel.kernelexpand("/path/to/kernel")158 self.assertEquals(ret_val, ["/path/to/kernel"])159 self.god.check_playback()160 def test_kernel_expand2(self):161 self.construct_kernel()162 kernel = "kernel.tar.gz"163 # record164 self.job.config_get.expect_call('mirror.mirrors').and_return('mirror')165 kernelexpand.expand_classic.expect_call(kernel,166 'mirror').and_return('patches')167 # run168 self.assertEquals(self.kernel.kernelexpand(kernel), 'patches')169 self.god.check_playback()170 def test_kernel_expand3(self):171 self.construct_kernel()172 kernel = "kernel.tar.gz"173 # record174 self.job.config_get.expect_call('mirror.mirrors')175 self.job.config_get.expect_call(176 'mirror.ftp_kernel_org').and_return('mirror')177 korg = 'http://www.kernel.org/pub/linux/kernel'178 mirrors = [179 [ korg + '/v2.6', 'mirror' + '/v2.6' ],180 [ korg + '/people/akpm/patches/2.6', 'mirror' + '/akpm' ],181 [ korg + '/people/mbligh', 'mirror' + '/mbligh' ],182 ]183 kernelexpand.expand_classic.expect_call(kernel,184 mirrors).and_return('patches')185 # run186 self.assertEquals(self.kernel.kernelexpand(kernel), 'patches')187 self.god.check_playback()188 def test_extract1(self):189 self.construct_kernel()190 # setup191 self.god.stub_function(self.kernel, "get_kernel_tree")192 # record193 os.path.exists.expect_call(self.base_tree).and_return(True)194 self.kernel.get_kernel_tree.expect_call(self.base_tree)195 self.job.record.expect_call('GOOD', self.subdir, 'kernel.extract')196 # run197 self.kernel.extract(self.base_tree)198 self.god.check_playback()199 self.god.unstub(self.kernel, "get_kernel_tree")200 def test_extract2(self):...
kernelexpand_unittest.py
Source:kernelexpand_unittest.py
1#!/usr/bin/python2import unittest3from kernelexpand import decompose_kernel4from kernelexpand import mirror_kernel_components5km = 'http://www.kernel.org/pub/linux/kernel/'6akpm = km + 'people/akpm/patches/'7kml = 'http://www.example.com/mirror/kernel.org/'8akpml = 'http://www.example.com/mirror/akpm/'9mirrorA = [10 [ akpm, akpml ],11 [ km, kml ],12]13class kernelexpandTest(unittest.TestCase):14 def test_decompose_simple(self):15 correct = [ [ km + 'v2.6/linux-2.6.23.tar.bz2' ] ]16 sample = decompose_kernel('2.6.23')17 self.assertEqual(sample, correct)18 def test_decompose_fail(self):19 success = False20 try:21 sample = decompose_kernel('1.0.0.0.0')22 success = True23 except NameError:24 pass25 except Exception, e:26 self.fail('expected NameError, got something else')27 if success:28 self.fail('expected NameError, was successful')29 def test_decompose_rcN(self):30 correct = [31 [ km + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',32 km + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2']33 ]34 sample = decompose_kernel('2.6.23-rc1')35 self.assertEqual(sample, correct)36 def test_decompose_mmN(self):37 correct = [38 [ km + 'v2.6/linux-2.6.23.tar.bz2' ],39 [ akpm + '2.6/2.6.23/2.6.23-mm1/2.6.23-mm1.bz2' ]40 ]41 sample = decompose_kernel('2.6.23-mm1')42 self.assertEqual(sample, correct)43 def test_decompose_gitN(self):44 correct = [45 [ km + 'v2.6/linux-2.6.23.tar.bz2' ],46 [ km + 'v2.6/snapshots/old/patch-2.6.23-git1.bz2',47 km + 'v2.6/snapshots/patch-2.6.23-git1.bz2']48 ]49 sample = decompose_kernel('2.6.23-git1')50 self.assertEqual(sample, correct)51 def test_decompose_rcN_mmN(self):52 correct = [53 [ km + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',54 km + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2' ],55 [ akpm + '2.6/2.6.23-rc1/2.6.23-rc1-mm1/2.6.23-rc1-mm1.bz2']56 ]57 sample = decompose_kernel('2.6.23-rc1-mm1')58 self.assertEqual(sample, correct)59 def test_mirrorA_simple(self):60 correct = [61 [ kml + 'v2.6/linux-2.6.23.tar.bz2',62 km + 'v2.6/linux-2.6.23.tar.bz2' ]63 ]64 sample = decompose_kernel('2.6.23')65 sample = mirror_kernel_components(mirrorA, sample)66 self.assertEqual(sample, correct)67 def test_mirrorA_rcN(self):68 correct = [69 [ kml + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',70 kml + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2',71 km + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',72 km + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2' ]73 ]74 sample = decompose_kernel('2.6.23-rc1')75 sample = mirror_kernel_components(mirrorA, sample)76 self.assertEqual(sample, correct)77 def test_mirrorA_mmN(self):78 correct = [79 [ kml + 'v2.6/linux-2.6.23.tar.bz2',80 km + 'v2.6/linux-2.6.23.tar.bz2'],81 [ akpml + '2.6/2.6.23/2.6.23-mm1/2.6.23-mm1.bz2',82 kml + 'people/akpm/patches/2.6/2.6.23/2.6.23-mm1/2.6.23-mm1.bz2',83 akpm + '2.6/2.6.23/2.6.23-mm1/2.6.23-mm1.bz2' ]84 ]85 sample = decompose_kernel('2.6.23-mm1')86 sample = mirror_kernel_components(mirrorA, sample)87 self.assertEqual(sample, correct)88 def test_mirrorA_gitN(self):89 correct = [90 [ kml + 'v2.6/linux-2.6.23.tar.bz2',91 km + 'v2.6/linux-2.6.23.tar.bz2'],92 [ kml + 'v2.6/snapshots/old/patch-2.6.23-git1.bz2',93 kml + 'v2.6/snapshots/patch-2.6.23-git1.bz2',94 km + 'v2.6/snapshots/old/patch-2.6.23-git1.bz2',95 km + 'v2.6/snapshots/patch-2.6.23-git1.bz2' ]96 ]97 sample = decompose_kernel('2.6.23-git1')98 sample = mirror_kernel_components(mirrorA, sample)99 self.assertEqual(sample, correct)100 def test_mirrorA_rcN_mmN(self):101 correct = [102 [ kml + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',103 kml + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2',104 km + 'v2.6/testing/v2.6.23/linux-2.6.23-rc1.tar.bz2',105 km + 'v2.6/testing/linux-2.6.23-rc1.tar.bz2'],106 [ akpml + '2.6/2.6.23-rc1/2.6.23-rc1-mm1/2.6.23-rc1-mm1.bz2',107 kml + 'people/akpm/patches/2.6/2.6.23-rc1/2.6.23-rc1-mm1/2.6.23-rc1-mm1.bz2',108 akpm + '2.6/2.6.23-rc1/2.6.23-rc1-mm1/2.6.23-rc1-mm1.bz2' ]109 ]110 sample = decompose_kernel('2.6.23-rc1-mm1')111 sample = mirror_kernel_components(mirrorA, sample)112 self.assertEqual(sample, correct)113if __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!!