Best Python code snippet using assertpy_python
test_Array.py
Source:test_Array.py
...38 assert a.__eq__([1., 0., 3.1,]) == False39 assert a.__eq__(["ja"]) == False40 assert a.__eq__([1., 0., "3"]) == False41 print("test_eq OK")42def test_is_equal():43 # test is_equal44 a = Array((3,), True, False, 3)45 assert a.is_equal(1.) == [True, False, False]46 assert a.is_equal([1., 0., 3.]) == [True, True, True]47 assert a.is_equal([2., 3., 4.]) == [False, False, False]48 print("test_is_equal OK")49def test_min_element():50 # test find smallest element51 a = Array((3,), True, False, 3)52 b = Array((4,), 5, 10, 2, 87)53 assert a.min_element() == 0.54 assert b.min_element() == 2.55 print("test min_element OK")56def test_isLegalType():57 # test isLegalType58 homo_array = Array((3,), 2., 2., 2.)59 assert Array.isLegalType(homo_array) == True60 try:61 not_homo_array = Array((3,), 2., "ja", True)62 except ValueError as valueError:63 # if we get here everything happened as planned64 print("test_isLegalType OK")65# calling test functions for 1d array66test_str()67test_add()68test_sub()69test_mul()70test_eq()71test_is_equal()72test_min_element()73test_isLegalType()74# task 3.3 - Tests for 2D arrays75def test2d_add():76 # test add for 2d array77 a = Array((2,2), 1, 2, 3, 4)78 print(a.__add__([0.1, 0.2, 0.3, 0.4]))79 assert a.__add__([0.1, 0.2, 0.3, 0.4]) == [1.1, 2.2, 3.3, 4.4]80 print("test2d_add OK")81def test2d_sub():82 # test sub for 2d array83 a = Array((2,2), 1, 2, 3, 4)84 assert a.__sub__([1., 1., 1., 1.]) == [0., 1., 2., 3.]85 print("test2d_sub OK")...
custom-tests.py
Source:custom-tests.py
...18 def run_tests(self) -> None:19 """20 Runs all tests21 """22 self.test_is_equal()2324 def test_is_equal(self) -> str:25 """26 Tests if one string equals the other one27 """28 name1 = 'a'29 name2 = 'b'30 try:31 assert name1 == name2, f"[TEST FAILED] Nome {name1} !== {name2}"32 except AssertionError as error:33 self.failed_tests += 134 print(error)35 else:36 self.success_tests += 137 finally:38 self.result()
...
test_utils_box.py
Source:test_utils_box.py
1from unittest import TestCase2from utils_cv import utils_box3class Test_get_area(TestCase):4 def test_is_equal(self):5 area = utils_box.get_area([0, 0, 1, 1])6 self.assertEqual(area, 4)7class Test_box2poly(TestCase):8 def test_is_equal(self):9 poly = utils_box.box2poly([0, 0, 1, 1])10 self.assertEqual(poly, [0, 0, 1, 0, 1, 1, 0, 1])11class Test_boxes2bbox(TestCase):12 def test_is_equal(self):13 bbox = utils_box.boxes2bbox([[0, 0, 1, 1], [1, 0, 2, 1]])...
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!!