How to use parse_from_file method in autotest

Best Python code snippet using autotest_python

test_nonlinear_read_from_file.py

Source:test_nonlinear_read_from_file.py Github

copy

Full Screen

...7class TestParserFileRead(TestCase):8 @unittest.mock.patch('sys.stdout', new_callable=io.StringIO)9 def assert_stdout(self, file, expected_output, mock_stdout):10 from ETCetera.util.parsing.parser_nonlinear_systems import parse_from_file11 parse_from_file(file)12 self.assertEqual(mock_stdout.getvalue(), expected_output)13 def test_parse_from_file(self):14 from ETCetera.util.parsing.parser_nonlinear_systems import parse_from_file15 with self.assertRaises(SystemExit) as context:16 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_hyperbox_states_key.txt')17 self.assertEqual(context.exception.code, None)18 with self.assertRaises(SystemExit) as context:19 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_hyperbox_disturbances_key.txt')20 self.assertEqual(context.exception.code, None)21 with self.assertRaises(SystemExit) as context:22 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_dynamics_key.txt')23 self.assertEqual(context.exception.code, None)24 with self.assertRaises(SystemExit) as context:25 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_controller_key.txt')26 self.assertEqual(context.exception.code, None)27 with self.assertRaises(SystemExit) as context:28 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_triggering_condition_key.txt')29 self.assertEqual(context.exception.code, None)30 with self.assertRaises(SystemExit) as context:31 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_triggering_times_key.txt')32 self.assertEqual(context.exception.code, None)33 with self.assertRaises(SystemExit) as context:34 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_lyapunov_func_key.txt')35 self.assertEqual(context.exception.code, None)36 with self.assertRaises(SystemExit) as context:37 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_solver_options_key.txt')38 self.assertEqual(context.exception.code, None)39 with self.assertRaises(SystemExit) as context:40 parse_from_file('/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_linesearch_options_key.txt')41 self.assertEqual(context.exception.code, None)42 # Solution one: testing print with @patch43 @patch('sys.stdout', new_callable=io.StringIO)44 def test_foo_one(mock_stdout):45 parse_from_file(46 '/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_hyperbox_states_key.txt')47 assert mock_stdout.getvalue() == "Incorrect key string on line : 1"48 # Solution two: testing print with with-statement49 def test_foo_two(self):50 with patch('sys.stdout', new=io.StringIO()) as fake_out:51 parse_from_file(52 '/Users/gmaddodi/Downloads/control_systems_abstractions/tests/parser_tests/nonlinear_systems_utils/incorrect_hyperbox_states_key.txt')...

Full Screen

Full Screen

qrtools.py

Source:qrtools.py Github

copy

Full Screen

1from config.api_tools import categorise_the_dict, parse_from_file, set_key2# Get extensions from file3@parse_from_file(r'..\offline\sources\ext_ga_8')4@categorise_the_dict('name')5def get_apps_file(ext_dict):6 return ext_dict7# Get LSs from file8@parse_from_file(r'..\offline\sources\ls_ga_8')9@categorise_the_dict('status')10def get_ls_types_file(ls_dict):11 return ls_dict12# Get all hosts13@parse_from_file(r'..\offline\sources\hosts_ga_8')14@categorise_the_dict('status')15def get_deployment_hosts(host_dict):16 return host_dict17# Get all offenses18@parse_from_file(r'..\offline\sources\offenses_ga_8')19@categorise_the_dict('status')20def get_offenses(off_dict):21 return off_dict22# Get all rules23@parse_from_file(r'..\offline\sources\rules_ga_8')24@categorise_the_dict('type')25def get_rules(rules_dict):26 return rules_dict27# Get Network Hierarchy28@parse_from_file(r'..\offline\sources\networkh_ga_8')29@categorise_the_dict('description')30def get_net_h(net_dict):31 return net_dict32# Get reference data set33@parse_from_file(r'..\offline\sources\refset_ga_8')34@set_key('set')35def get_ref_set(set_list):36 return set_list37# Get reference data map38@parse_from_file(r'..\offline\sources\refmap_ga_8')39@set_key('map')40def get_ref_map(map_list):41 return map_list42# Get reference data map of set43@parse_from_file(r'..\offline\sources\mapofset_ga_8')44@set_key('map_of_sets')45def get_ref_map_of_sets(map_of_sets_list):46 return map_of_sets_list47# Get reference data tables48@parse_from_file(r'..\offline\sources\reftables_ga_8')49@set_key('table')50def get_ref_tables(tables_list):51 return tables_list52# Sum all reference data in 1 list53def get_all_ref():...

Full Screen

Full Screen

test_parser.py

Source:test_parser.py Github

copy

Full Screen

...7 files_to_test = os.listdir(PATH_VALID)8 for f in files_to_test:9 f = PATH_VALID + '/' + f10 if os.path.isfile(f):11 puzzle = parse_from_file(f)12 if puzzle is None:13 raise Exception("puzzle is None with a valid file (%s)" % (f))14 print("check with %s -> OK" % (f))15def test_invalid():16 files_to_test = os.listdir(PATH_INVALID)17 for f in files_to_test:18 f = PATH_INVALID + '/' + f19 if os.path.isfile(f):20 puzzle = parse_from_file(f)21 if puzzle is not None:22 raise Exception("puzzle is not None with an ivalid file (%s)" % (f))23 print("check with %s -> OK" % (f))24 files_to_test = FILES_INVALID_TO_TEST25 for f in files_to_test:26 puzzle = parse_from_file(f)27 if puzzle is not None:28 raise Exception("puzzle is not None with an ivalid file (%s)" % (f))...

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