How to use parse_input method in autotest

Best Python code snippet using autotest_python

main.py

Source:main.py Github

copy

Full Screen

...12 for item in data:13 if isinstance(item, Fact):14 self.KB.kb_assert(item)15 def test1(self):16 ask1 = read.parse_input("fact: (color bigbox red)")17 print(' Asking if', ask1)18 answer = self.KB.kb_ask(ask1)19 self.assertEqual(answer[0].bindings, [])20 #self.assertEqual(aswer.list_of_bindings[0][1][0], ask1)21 def test2(self):22 ask1 = read.parse_input("fact: (color littlebox red)")23 print(' Asking if', ask1)24 answer = self.KB.kb_ask(ask1)25 self.assertFalse(answer)26 def test3(self):27 ask1 = read.parse_input("fact: (color ?X red)")28 print(' Asking if', ask1)29 answer = self.KB.kb_ask(ask1)30 self.assertEqual(str(answer[0]), "?X : bigbox")31 self.assertEqual(str(answer[1]), "?X : pyramid3")32 self.assertEqual(str(answer[2]), "?X : pyramid4")33 def test4(self):34 ask1 = read.parse_input("fact: (color bigbox ?Y)")35 print(' Asking if', ask1)36 answer = self.KB.kb_ask(ask1)37 self.assertEqual(str(answer[0]), "?Y : red")38 def test5(self):39 ask1 = read.parse_input("fact: (color ?X ?Y)")40 print(' Asking if', ask1)41 answer = self.KB.kb_ask(ask1)42 self.assertEqual(str(answer[0]), "?X : bigbox, ?Y : red")43 self.assertEqual(str(answer[1]), "?X : littlebox, ?Y : blue")44 self.assertEqual(str(answer[2]), "?X : pyramid1, ?Y : blue")45 self.assertEqual(str(answer[3]), "?X : pyramid2, ?Y : green")46 self.assertEqual(str(answer[4]), "?X : pyramid3, ?Y : red")47 self.assertEqual(str(answer[5]), "?X : pyramid4, ?Y : red")48 #assert tests49 def test6(self):50 self.KB.kb_assert(read.parse_input("fact: (color box34 blue)"))51 self.KB.kb_assert(read.parse_input("fact: (color box34 red)"))52 a = self.KB.kb_ask(read.parse_input("fact: (color box34 ?Y)"))53 self.assertEqual(str(a[0]), "?Y : blue")54 self.assertEqual(str(a[1]), "?Y : red")55 b = self.KB.kb_ask(read.parse_input("fact: (color box34 blue)"))56 self.assertEqual(b[0].bindings, [])57 c = self.KB.kb_ask(read.parse_input("fact: (color box400 blue)"))58 self.assertEqual(c, False)59 print("Test 6 passed!")60 def test7(self):61 self.KB.kb_assert(read.parse_input("fact: (color box37 blue)"))62 self.KB.kb_assert(read.parse_input("fact: (color box37 blue)"))63 self.assertEqual(True, True)64 ask1 = read.parse_input("fact: (color ?X blue)")65 answer = self.KB.kb_ask(ask1)66 self.assertEqual(str(answer[0]), "?X : littlebox")67 self.assertEqual(str(answer[1]), "?X : pyramid1")68 self.assertEqual(str(answer[2]), "?X : box37")69 print("{!r}".format(answer))70class KBTest2(unittest.TestCase):71 def setUp(self):72 # Assert starter facts73 file = 'statements_kb2.txt'74 data = read.read_tokenize(file)75 self.KB = KnowledgeBase([], [])76 for item in data:77 if isinstance(item, Fact):78 self.KB.kb_assert(item)79 def test2_1(self):80 ask1 = read.parse_input("fact: (attacked Ai Nosliw)")81 print(' Asking if', ask1)82 answer = self.KB.kb_ask(ask1)83 self.assertEqual(answer[0].bindings, [])84 #self.assertEqual(aswer.list_of_bindings[0][1][0], ask1)85 print("test 2_1 passed!")86 def test2_2(self):87 ask1 = read.parse_input("fact: (color littlebox red)")88 print(' Asking if', ask1)89 answer = self.KB.kb_ask(ask1)90 self.assertFalse(answer)91 print("test 2_2 passed!")92 def test2_3(self):93 a1 = read.parse_input("fact: (inst Harry Wizard)")94 a2 = read.parse_input("fact: (inst Ron Wizard)")95 a3 = read.parse_input("fact: (inst Hermione Sorceress)")96 self.KB.kb_assert(a1)97 self.KB.kb_assert(a2)98 self.KB.kb_assert(a3)99 ask1 = read.parse_input("fact: (inst ?X Wizard)")100 print(' Asking if', ask1)101 answer = self.KB.kb_ask(ask1)102 self.assertEqual(str(answer[0]), "?X : Harry")103 self.assertEqual(str(answer[1]), "?X : Ron")104 ask2 = read.parse_input("fact: (inst ?X Sorceress)")105 print(' Asking if', ask2)106 answer2 = self.KB.kb_ask(ask2)107 self.assertEqual(str(answer2[0]), "?X : Sarorah")108 self.assertEqual(str(answer2[1]), "?X : Hermione")109 print("test 2_3 passed!")110def test2_4(self):111 ask1 = read.parse_input("fact: (hero ?Y)")112 print(' Asking if', ask1)113 answer = self.KB.kb_ask(ask1)114 self.assertEqual(str(answer[0]), "?Y : Ai")115 print("test 2_4 passed!")116def test2_5(self):117 ask1 = read.parse_input("fact: (color ?X ?Y)")118 print(' Asking if', ask1)119 answer = self.KB.kb_ask(ask1)120 self.assertEqual(str(answer[0]), "?X : bigbox, ?Y : red")121 self.assertEqual(str(answer[1]), "?X : littlebox, ?Y : blue")122 self.assertEqual(str(answer[2]), "?X : pyramid1, ?Y : blue")123 self.assertEqual(str(answer[3]), "?X : pyramid2, ?Y : green")124 self.assertEqual(str(answer[4]), "?X : pyramid3, ?Y : red")125 self.assertEqual(str(answer[5]), "?X : pyramid4, ?Y : red")126#assert tests127def test2_6(self):128 self.KB.kb_assert(read.parse_input("fact: (color box34 blue)"))129 self.KB.kb_assert(read.parse_input("fact: (color box34 red)"))130 a = self.KB.kb_ask(read.parse_input("fact: (color box34 ?Y)"))131 self.assertEqual(str(a[0]), "?Y : blue")132 self.assertEqual(str(a[1]), "?Y : red")133 b = self.KB.kb_ask(read.parse_input("fact: (color box34 blue)"))134 self.assertEqual(b[0].bindings, [])135 c = self.KB.kb_ask(read.parse_input("fact: (color box400 blue)"))136 self.assertEqual(c, False)137 print("Test 6 passed!")138def test2_7(self):139 self.KB.kb_assert(read.parse_input("fact: (color box37 blue)"))140 self.KB.kb_assert(read.parse_input("fact: (color box37 blue)"))141 self.assertEqual(True, True)142 ask1 = read.parse_input("fact: (color ?X blue)")143 answer = self.KB.kb_ask(ask1)144 self.assertEqual(str(answer[0]), "?X : littlebox")145 self.assertEqual(str(answer[1]), "?X : pyramid1")146 self.assertEqual(str(answer[2]), "?X : box37")147 print("{!r}".format(answer))148if __name__ == '__main__':...

Full Screen

Full Screen

test_convert_IP_to_SI.py

Source:test_convert_IP_to_SI.py Github

copy

Full Screen

1from ast import parse2from honeybee_ph_utils.units import parse_input, convert3def test_positive_inches():4 assert convert(*parse_input("3 IN"), "IN") == 35 assert convert(*parse_input("3 IN"), "FT") == 0.256 assert convert(*parse_input("4 IN"), "M") == 0.10167 assert convert(*parse_input("4 IN"), "CM") == 10.168 assert convert(*parse_input("4 IN"), "MM") == 101.69def test_negative_inches():10 assert convert(*parse_input("-3 IN"), "IN") == -311 assert convert(*parse_input("-3 IN"), "FT") == -0.2512 assert convert(*parse_input("-4 IN"), "M") == -0.101613 assert convert(*parse_input("-4 IN"), "CM") == -10.1614 assert convert(*parse_input("-4 IN"), "MM") == -101.615def test_positive_feet():16 assert convert(*parse_input("3 FT"), "FT") == 317 assert convert(*parse_input("3 FT"), "IN") == 3618 assert convert(*parse_input("4 FT"), "M") == 1.219219 assert convert(*parse_input("4 FT"), "CM") == 121.9220 assert convert(*parse_input("4 FT"), "MM") == 1219.221def test_negative_feet():22 assert convert(*parse_input("-3 FT"), "FT") == -323 assert convert(*parse_input("-3 FT"), "IN") == -3624 assert convert(*parse_input("-4 FT"), "M") == -1.219225 assert convert(*parse_input("-4 FT"), "CM") == -121.92...

Full Screen

Full Screen

test_parse_inputs.py

Source:test_parse_inputs.py Github

copy

Full Screen

1from honeybee_ph_utils.units import parse_input2def test_parse_string_no_units():3 assert parse_input("4") == ("4", None)4 assert parse_input(4) == ("4", None)5 assert parse_input("-4") == ("-4", None)6 assert parse_input(-4) == ("-4", None)7 assert parse_input("4.0") == ("4.0", None)8 assert parse_input(4.0) == ("4.0", None)9 assert parse_input("-4.0") == ("-4.0", None)10 assert parse_input(-4.0) == ("-4.0", None)11def test_parse_string_with_units():12 assert parse_input("4 BTU/HR-FT-F") == ("4", "BTU/HR-FT-F")13 assert parse_input("4 BTU/HR-FT-F") == ("4", "BTU/HR-FT-F")14 assert parse_input("4BTU/HR-FT-F") == ("4", "BTU/HR-FT-F")15 assert parse_input("-4 BTU/HR-FT-F") == ("-4", "BTU/HR-FT-F")16 assert parse_input("4.0 BTU/HR-FT-F") == ("4.0", "BTU/HR-FT-F")17 assert parse_input("4.0BTU/HR-FT-F") == ("4.0", "BTU/HR-FT-F")18 assert parse_input("-4.0 BTU/HR-FT-F") == ("-4.0", "BTU/HR-FT-F")19def test_parse_string_no_value():...

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