How to use changer method in autotest

Best Python code snippet using autotest_python

test_CaseChanger.py

Source:test_CaseChanger.py Github

copy

Full Screen

1import unittest2from Src.StringFuncs.CaseChanger import CaseChanger3class CaseChangerTestCases(unittest.TestCase):4 def test_camelCase_case_changer_one(self):5 InitCase = CaseChanger("camelCase")6 output = CaseChanger.case_selector(InitCase, "PascalcaseToCamelcase")7 self.assertEqual("pascalcaseToCamelcase", output)8 @unittest.skip("reason for skipping")9 def test_camelCase_case_changer_two(self):10 InitCase = CaseChanger("camelCase")11 output = CaseChanger.case_selector(InitCase, "RanDom_CapitAlised_WOrd")12 self.assertNotEqual("RanDom_CapitAlised_WOrd", output)13 self.assertEqual("randomCapitalisedWord", output)14 @unittest.skip("reason for skipping")15 def test_camelCase_case_changer_three(self):16 InitCase = CaseChanger("camelCase")17 output = CaseChanger.case_selector(InitCase, "alllowercase")18 self.assertNotEqual("alllowercase", output)19 self.assertEqual("allLowerCase", output)20 @unittest.skip("reason for skipping")21 def test_camelCase_case_changer_four(self):22 InitCase = CaseChanger("camelCase")23 output = CaseChanger.case_selector(InitCase, "ALLUPERCASE")24 self.assertNotEqual("alllowercase", output)25 self.assertEqual("allLowerCase", output)26 def test_lower_snake_case_case_changer_one(self):27 InitCase = CaseChanger("lower_snake_case")28 output = CaseChanger.case_selector(InitCase, "PascalcaseToLowerSnakecase")29 self.assertEqual("pascalcase_to_lower_snakecase", output)30 @unittest.skip("reason for skipping")31 def test_lower_snake_case_case_changer_two(self):32 InitCase = CaseChanger("lower_snake_case")33 output = CaseChanger.case_selector(InitCase, "RanDom_CapitAlised_WOrd")34 self.assertNotEqual("RanDom_CapitAlised_WOrd", output)35 self.assertEqual("random_capitalised_word", output)36 @unittest.skip("reason for skipping")37 def test_snake_case_case_case_changer_three(self):38 InitCase = CaseChanger("camelCase")39 output = CaseChanger.case_selector(InitCase, "alllowercase")40 self.assertNotEqual("alllowercase", output)41 self.assertEqual("all_lower_case", output)42 def test_UPPER_SNAKE_CASE_case_changer_one(self):43 InitCase = CaseChanger("UPPER_SNAKE_CASE")44 output = CaseChanger.case_selector(InitCase, "PascalcaseToUpperSnakecase")45 self.assertEqual("PASCALCASE_TO_UPPER_SNAKECASE", output)46 @unittest.skip("reason for skipping")47 def test_UPPER_SNAKE_CASE_case_changer_two(self):48 InitCase = CaseChanger("UPPER_SNAKE_CASE")49 output = CaseChanger.case_selector(InitCase, "RanDom_CapitAlised_WOrd")50 self.assertNotEqual("RanDom_CapitAlised_WOrd", output)51 self.assertEqual("RANDOM_CAPITALISED_WORD", output)52 @unittest.skip("reason for skipping")53 def test_UPPER_SNAKE_CASE_case_changer_three(self):54 InitCase = CaseChanger("UPPER_SNAKE_CASE")55 output = CaseChanger.case_selector(InitCase, "alllowercase")56 self.assertNotEqual("alllowercase", output)57 self.assertEqual("ALL_LOWER_CASE", output)58 def test_PascalCase_case_changer_one(self):59 InitCase = CaseChanger("PascalCase")60 output = CaseChanger.case_selector(InitCase, "PascalcaseTest")61 self.assertEqual("PascalcaseTest", output)62 @unittest.skip("reason for skipping")63 def test_PascalCase_case_changer_two(self):64 InitCase = CaseChanger("PascalCase")65 output = CaseChanger.case_selector(InitCase, "RanDom_CapitAlised_WOrd")66 self.assertNotEqual("RanDom_CapitAlised_WOrd", output)67 self.assertEqual("RandomCapitalisedWord", output)68 @unittest.skip("reason for skipping")69 def test_PascalCase_case_changer_three(self):70 InitCase = CaseChanger("PascalCase")71 output = CaseChanger.case_selector(InitCase, "alllowercase")72 self.assertNotEqual("alllowercase", output)73 self.assertEqual("AllLowerCase", output)74if __name__ == '__main__':...

Full Screen

Full Screen

parameterchanger_test.py

Source:parameterchanger_test.py Github

copy

Full Screen

...6from parameterchanger import ParameterChangerManager7class TestParameterChanger(unittest.TestCase):8 def setUp(self):9 pass10 def test_changer(self):11 script_str = r'''12x = func1(a,b,c)13func2(1,2,3)'''14 modified_script_str = r'''15x = func1(00,11,22)16func2(1,2,3)'''17 script = Script(script_str)18 manager = ParameterChangerManager(script)19 changer = manager._create_changer_from_pos(0)20 changer.set_parameters(['00', '11', '22'])21 self.assertEqual(script.get_code_as_str(), modified_script_str)22 params = changer.get_parameters()23 self.assertEqual(params[0], '00')24 self.assertEqual(params[1], '11')25 self.assertEqual(params[2], '22')26 27 changer.set_parameters(['a','b', 'c'])28 self.assertEqual(script.get_code_as_str(), script_str)29 params = changer.get_parameters()30 self.assertEqual(params[0], 'a')31 self.assertEqual(params[1], 'b')32 self.assertEqual(params[2], 'c')33 34 35 def test_create_changer_from_pos(self):36 script_str = r'''37func1(38 param1,39 param2,40 func32(adfd),41 func3(1,2,3,4,42 "abcdefg(fsdsd)"),43 func39(1,2,3,4,44 "abc'defg(fsdsd)"),45 [1, 2, 3, 4],46 func4(1,2,3,4,47 "abc'd\"ef'g(fsdsd)"),48 ")))))))",49 '((((((')50func2(1,2,3)'''51 script = Script(script_str)52 manager = ParameterChangerManager(script)53 changer = manager._create_changer_from_pos(0)54 params = changer.get_parameters()55 self.assertEqual(params[0], 'param1')56 self.assertEqual(params[1], 'param2')57 self.assertEqual(params[2], 'func32(adfd)')58 self.assertEqual(params[3], 'func3(1,2,3,4,\n "abcdefg(fsdsd)")')59 self.assertEqual(params[4], 'func39(1,2,3,4,\n "abc\'defg(fsdsd)")')60 self.assertEqual(params[5], '[1, 2, 3, 4]')61 self.assertEqual(params[6], 'func4(1,2,3,4,\n "abc\'d\\"ef\'g(fsdsd)")')62 self.assertEqual(params[7], '")))))))"')63 self.assertEqual(params[8], '\'((((((\'')64 65 def test_annonate_script(self):66 prev_function_names = parameterchanger.PARAMETER_CHANGER_FUNCTIONS67 parameterchanger.PARAMETER_CHANGER_FUNCTIONS = [68 'func_32','func3','func1','func2', 'func4']69 try:70 script_str = r'''71func1(72 param1,73 param2,74 func_32(adfd),75 func3(1,2,3,4,76 "abcdefg(fsdsd)"),77 func39(1,2,3,4,78 "abc'defg(fsdsd)"),79 func4(1,2,3,4,80 "abc'd\"ef'g(fsdsd)"),81 ")))))))",82 '((((((')83func2(1,2,3)'''84 script = Script(script_str)85 manager = ParameterChangerManager(script)86 res = manager.annonate_script()87 annoated_str = r'''88services.set_current_changer(0,func1)(89 param1,90 param2,91 services.set_current_changer(1,func_32)(adfd),92 services.set_current_changer(2,func3)(1,2,3,4,93 "abcdefg(fsdsd)"),94 func39(1,2,3,4,95 "abc'defg(fsdsd)"),96 services.set_current_changer(3,func4)(1,2,3,4,97 "abc'd\"ef'g(fsdsd)"),98 ")))))))",99 '((((((')100services.set_current_changer(4,func2)(1,2,3)'''101 self.assertEqual(res, annoated_str)102 finally:103 parameterchanger.PARAMETER_CHANGER_FUNCTIONS = prev_function_names104if __name__ == '__main__':...

Full Screen

Full Screen

solution.py

Source:solution.py Github

copy

Full Screen

1import numpy as np2t = int(input())3for i in range(t):4 rc = input().split()5 r1 = int(rc[0])6 c1 = int(rc[1])7 img1 = []8 for j in range(r1):9 img1.append(list(input()))10 11 rc = input().split()12 r2 = int(rc[0])13 c2 = int(rc[1])14 img2 = []15 for j in range(r2):16 img2.append(list(input()))17 18 img1 = np.array(img1)19 img2 = np.array(img2)20 if (r1*c1) < (r2*c2):21 changer = img122 fixed = img223 changerC = c124 changerR = r125 fixedC = c226 fixedR = r227 else:28 changer = img229 fixed = img130 changerC = c231 changerR = r232 fixedC = c133 fixedR = r134 35 changer2 = np.flip(changer, 0)36 changer11 = np.rot90(changer)37 changer12 = np.rot90(changer11)38 changer13 = np.rot90(changer12)39 changer21 = np.rot90(changer2)40 changer22 = np.rot90(changer21)41 changer23 = np.rot90(changer22)42 changes1 = [changer,changer12,changer2,changer22]43 changes2 = [changer11, changer13, changer21, changer23]44 45 fixed1 = fixed46 for j in range(changerR-1):47 fixed1 = np.vstack([['.']*fixedC, fixed1])48 fixed1 = np.vstack([fixed1, ['.']*fixedC])49 for j in range(changerC-1):50 fixed1 = np.insert(fixed1, 0, '.', axis=1)51 fixed1 = np.insert(fixed1, fixedC+1+j, '.', axis=1)52 53 answer = 054 for j in range(fixedR+changerR-1):55 for k in range(fixedC+changerC-1):56 for z in changes1:57 slidedWindow = fixed1[j:j+changerR, k:k+changerC]58 temp = np.sum((slidedWindow=='#') & (z=='#'))59 if temp>answer:60 answer=temp61 62 fixed2 = fixed63 for j in range(changerC-1):64 fixed2 = np.vstack([['.']*fixedC, fixed2])65 fixed2 = np.vstack([fixed2, ['.']*fixedC])66 for j in range(changerR-1):67 fixed2 = np.insert(fixed2, 0, '.', axis=1)68 fixed2 = np.insert(fixed2, fixedC+1+j, '.', axis=1)69 for j in range(fixedR+changerC-1):70 for k in range(fixedC+changerR-1):71 for z in changes2:72 slidedWindow = fixed2[j:j+changerC, k:k+changerR]73 temp = np.sum((slidedWindow=='#') & (z=='#'))74 if temp>answer:75 answer=temp76 ...

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