How to use check_kernel method in autotest

Best Python code snippet using autotest_python

check_kernel_test.py

Source:check_kernel_test.py Github

copy

Full Screen

1#!/usr/bin/python2from __future__ import division3import sys4import unittest5from check_kernel import clean_kernel_version, Version6import check_kernel7def patch_object(obj, function, return_value=None):8 """A simple replacement for unittest.mock.patch_object()9 It is not meant to used with the 'with' statement or as a decorator, unlike10 unittest.mock.patch_object(). To support Python <= 3.2."""11 def our_function():12 return return_value13 obj.__dict__[function] = our_function14# Patch up unittest.TestCase15if not hasattr(unittest.TestCase, 'assertGreater'):16 unittest.TestCase.assertGreater = lambda self, a, b: self.assertTrue(a > b)17if not hasattr(unittest.TestCase, 'assertLess'):18 unittest.TestCase.assertLess = lambda self, a, b: self.assertTrue(a < b)19class CleanKernelVersionTestCase(unittest.TestCase):20 def testDebianVanilla(self):21 versions = [('3.16.7-ckt9-3~deb8u2', '3.16.7-ckt9-3~deb8u2')]22 for dirty, clean in versions:23 self.assertEqual(clean_kernel_version(dirty), Version(clean))24 def testDebianProxmox(self):25 versions = [('5.13.19-14', '5.13.19-14')]26 for dirty, clean in versions:27 self.assertEqual(clean_kernel_version(dirty), Version(clean))28 def testFedora(self):29 versions = [30 ('4.0.4-301.fc22.x86_64', '4.0.4-301'),31 ('4.0.0-1.fc22', '4.0.0-1'),32 ]33 for dirty, clean in versions:34 self.assertEqual(clean_kernel_version(dirty), Version(clean))35 def testRHEL(self):36 versions = [37 ('4.18.0-348.12.2.el8_5', '4.18.0-348.12.2'),38 ('4.18.0-348.el8.0.2', '4.18.0-348')39 ]40 for dirty, clean in versions:41 self.assertEqual(clean_kernel_version(dirty), Version(clean))42class RunningKernelVersionTestCase(unittest.TestCase):43 def testFedora(self):44 patch_object(check_kernel, 'proc_version', return_value='Linux version 4.0.3-301.fc22.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 5.1.1 20150422 (Red Hat 5.1.1-1) (GCC) ) #1 SMP Thu May 21 13:10:33 UTC 2015')45 self.assertEqual(check_kernel.running_kernel_version(),46 Version('4.0.3-301'))47 def testDebianVanilla(self):48 patch_object(check_kernel, 'proc_version', return_value='Linux version 4.19.0-5-amd64 (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-7)) #1 SMP Debian 4.19.37-5 (2019-06-19)')49 self.assertEqual(check_kernel.running_kernel_version(),50 Version('4.19.37-5'))51 patch_object(check_kernel, 'proc_version', return_value='Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.7-ckt9-3~deb8u1 (2015-04-24)')52 self.assertEqual(check_kernel.running_kernel_version(),53 Version('3.16.7-ckt9-3~deb8u1'))54 patch_object(check_kernel, 'proc_version', return_value='Linux version 2.6.32-5-amd64 (Debian 2.6.32-48squeeze11) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Wed Feb 18 13:14:10 UTC 2015')55 self.assertEqual(check_kernel.running_kernel_version(),56 Version('2.6.32-48squeeze11'))57 patch_object(check_kernel, 'proc_version', return_value='Linux version 5.10.0-8-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.46-4 (2021-08-03)')58 self.assertEqual(check_kernel.running_kernel_version(),59 Version('5.10.46-4'))60 def testDebianProxmox(self):61 patch_object(check_kernel, 'proc_version', return_value='Linux version 5.4.162-1-pve (build@proxmox) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP PVE 5.4.162-2 (Thu, 20 Jan 2022 16:38:53 +0100)')62 self.assertEqual(check_kernel.running_kernel_version(),63 Version('5.4.162-2'))64 patch_object(check_kernel, 'proc_version', return_value='Linux version 5.13.19-6-pve (build@proxmox) (gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP PVE 5.13.19-14 (Thu, 10 Mar 2022 16:24:52 +0100)')65 self.assertEqual(check_kernel.running_kernel_version(),66 Version('5.13.19-14'))67class VersionTestCase(unittest.TestCase):68 def testStr(self):69 self.assertEqual(str(Version('1.0')), '1.0')70 def testComparingTrivial(self):71 self.assertEqual(Version('1.0'), Version('1.0'))72 self.assertEqual(Version('2.6.32-5foo1'), Version('2.6.32-5foo1'))73 self.assertGreater(Version('2.0'), Version('1.0'))74 def testComparingNonTrivial(self):75 # lower < greater76 versions = [('2.2', '2.12'),77 ('3.12-2', '3.12-12'),78 ('2.6.32-5foo0', '2.6.32-5foo1'),79 ('3.4.15-2', '3.16.7-ckt9-3~deb8u1'),80 ('3.2.4', '3.2.4+2'),81 ('4.18.0-348', '4.18.0-348.12.2')]82 for lower, greater in versions:83 self.assertGreater(Version(greater), Version(lower))84 self.assertLess(Version(lower), Version(greater))85 def testSorting(self):86 l = [Version('3.16.5-1'), Version('3.2.60-1+deb7u3'),87 Version('3.16.3-2'), Version('3.16.7-ckt9-3~deb8u1'),88 Version('3.14.15-2')]89 self.assertEqual(sorted(l)[0], Version('3.2.60-1+deb7u3'))90 self.assertEqual(sorted(l)[-1], Version('3.16.7-ckt9-3~deb8u1'))91if __name__ == '__main__':...

Full Screen

Full Screen

test_kernels.py

Source:test_kernels.py Github

copy

Full Screen

...23 os.remove(filename)24# ============25# check kernel26# ============27def check_kernel(kernel):28 """29 Checks ``glearn.kernels`` classes.30 """31 x = 0.532 kernel(x)33 kernel(x, derivative=1)34 kernel(x, derivative=2)35 kernel.plot(compare_numerical=True, test=True)36 remove_file('kernel.svg')37 print('OK')38# ============39# test kernels40# ============41def test_kernels():42 """43 A test for :mod:`glearn.kernels` module.44 """45 check_kernel(kernels.Exponential())46 check_kernel(kernels.SquareExponential())47 check_kernel(kernels.Linear())48 check_kernel(kernels.RationalQuadratic(alpha=1.2))49 check_kernel(kernels.Matern(nu=1.2))50# ===========51# System Main52# ===========53if __name__ == "__main__":...

Full Screen

Full Screen

test_validations.py

Source:test_validations.py Github

copy

Full Screen

1import numpy as np2import pytest3from GPro.validations import check_kernel4def test_check_kernel():5 X = np.array(6 [7 [0.1, 0.2, 0.3],8 [0.4, 0.5, 0.6],9 ]10 )11 assert check_kernel(X, length_scale=1.0) is None12 assert check_kernel(X, length_scale=np.array([0.3, 0.4, 0.5])) is None13 with pytest.raises(AssertionError):14 check_kernel(X, length_scale=np.array([0.3, 0.4]))15 with pytest.raises(ValueError):16 check_kernel(X, length_scale="1.0")17 with pytest.raises(TypeError):18 check_kernel(X, length_scale=np.array(["0.3", "0.4", "0.5"]))19 with pytest.raises(ValueError):20 check_kernel(X, length_scale=np.array([0.3, -0.4, 0.5]))21 with pytest.raises(ValueError):22 check_kernel(X, length_scale=np.array([0.3, 0.4, 0.0]))23 # Test nu parameter for Matern kernel:24 assert check_kernel(X, length_scale=1.0, nu=1.5) is None25 with pytest.raises(ValueError):26 check_kernel(X, length_scale=1.0, nu=0.0)27 with pytest.raises(ValueError):28 check_kernel(X, length_scale=1.0, nu=-1.5)29 with pytest.raises(ValueError):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful