Best Python code snippet using autotest_python
test_compliance_check_xml.py
Source:test_compliance_check_xml.py
...17 self.assertEqual(3, len(manager.steps))18 self.assertEqual(Status.FAILED, manager.steps[0].status)19 self.assertEqual(Status.NOT_EXECUTED, manager.steps[1].status)20 self.assertEqual(Status.NOT_EXECUTED, manager.steps[2].status)21 self.assertIn("No such file or directory", manager.format_step(0, verbose_level=1))22 manager.steps = []23 file_path_3 = os.path.join(script_dir, 'files/test_missing_submodels.xml')24 compliance_tool.check_schema(file_path_3, manager)25 self.assertEqual(3, len(manager.steps))26 self.assertEqual(Status.SUCCESS, manager.steps[0].status)27 self.assertEqual(Status.SUCCESS, manager.steps[1].status)28 self.assertEqual(Status.SUCCESS, manager.steps[2].status)29 manager.steps = []30 file_path_4 = os.path.join(script_dir, 'files/test_empty.xml')31 compliance_tool.check_schema(file_path_4, manager)32 self.assertEqual(3, len(manager.steps))33 self.assertEqual(Status.SUCCESS, manager.steps[0].status)34 self.assertEqual(Status.SUCCESS, manager.steps[1].status)35 self.assertEqual(Status.SUCCESS, manager.steps[2].status)36 manager.steps = []37 file_path_5 = os.path.join(script_dir, 'files/test_demo_full_example.xml')38 compliance_tool.check_schema(file_path_5, manager)39 self.assertEqual(3, len(manager.steps))40 self.assertEqual(Status.SUCCESS, manager.steps[0].status)41 self.assertEqual(Status.SUCCESS, manager.steps[1].status)42 self.assertEqual(Status.SUCCESS, manager.steps[2].status)43 def test_check_deserialization(self) -> None:44 manager = ComplianceToolStateManager()45 script_dir = os.path.dirname(__file__)46 file_path_1 = os.path.join(script_dir, 'files/test_not_found.xml')47 compliance_tool.check_deserialization(file_path_1, manager)48 self.assertEqual(2, len(manager.steps))49 self.assertEqual(Status.FAILED, manager.steps[0].status)50 self.assertEqual(Status.NOT_EXECUTED, manager.steps[1].status)51 self.assertIn("No such file or directory", manager.format_step(0, verbose_level=1))52 manager.steps = []53 file_path_2 = os.path.join(script_dir, 'files/test_not_deserializable_aas.xml')54 compliance_tool.check_deserialization(file_path_2, manager)55 self.assertEqual(2, len(manager.steps))56 self.assertEqual(Status.SUCCESS, manager.steps[0].status)57 self.assertEqual(Status.FAILED, manager.steps[1].status)58 self.assertIn("child of aas:assetAdministrationShells", manager.format_step(1, verbose_level=1))59 self.assertIn("doesn't match the expected tag aas:assetAdministrationShell",60 manager.format_step(1, verbose_level=1))61 manager.steps = []62 file_path_3 = os.path.join(script_dir, 'files/test_deserializable_aas_warning.xml')63 compliance_tool.check_deserialization(file_path_3, manager)64 self.assertEqual(2, len(manager.steps))65 self.assertEqual(Status.SUCCESS, manager.steps[0].status)66 self.assertEqual(Status.FAILED, manager.steps[1].status)67 self.assertIn("ValueError: A revision requires a version", manager.format_step(1, verbose_level=1))68 manager.steps = []69 file_path_4 = os.path.join(script_dir, 'files/test_empty.xml')70 compliance_tool.check_deserialization(file_path_4, manager)71 self.assertEqual(2, len(manager.steps))72 self.assertEqual(Status.SUCCESS, manager.steps[0].status)73 self.assertEqual(Status.SUCCESS, manager.steps[1].status)74 manager.steps = []75 file_path_4 = os.path.join(script_dir, 'files/test_empty.xml')76 compliance_tool.check_deserialization(file_path_4, manager)77 self.assertEqual(2, len(manager.steps))78 self.assertEqual(Status.SUCCESS, manager.steps[0].status)79 self.assertEqual(Status.SUCCESS, manager.steps[1].status)80 def test_check_aas_example(self) -> None:81 manager = ComplianceToolStateManager()82 script_dir = os.path.dirname(__file__)83 file_path_2 = os.path.join(script_dir, 'files/test_demo_full_example.xml')84 compliance_tool.check_aas_example(file_path_2, manager)85 self.assertEqual(3, len(manager.steps))86 self.assertEqual(Status.SUCCESS, manager.steps[0].status)87 self.assertEqual(Status.SUCCESS, manager.steps[1].status)88 self.assertEqual(Status.SUCCESS, manager.steps[2].status)89 manager.steps = []90 file_path_1 = os.path.join(script_dir, 'files/test_not_deserializable_aas.xml')91 compliance_tool.check_aas_example(file_path_1, manager)92 self.assertEqual(3, len(manager.steps))93 self.assertEqual(Status.SUCCESS, manager.steps[0].status)94 self.assertEqual(Status.FAILED, manager.steps[1].status)95 self.assertEqual(Status.NOT_EXECUTED, manager.steps[2].status)96 self.assertIn("child of aas:assetAdministrationShells", manager.format_step(1, verbose_level=1))97 self.assertIn("doesn't match the expected tag aas:assetAdministrationShell",98 manager.format_step(1, verbose_level=1))99 manager.steps = []100 file_path_3 = os.path.join(script_dir, 'files/test_demo_full_example_wrong_attribute.xml')101 compliance_tool.check_aas_example(file_path_3, manager)102 self.assertEqual(3, len(manager.steps))103 self.assertEqual(Status.SUCCESS, manager.steps[0].status)104 self.assertEqual(Status.SUCCESS, manager.steps[1].status)105 self.assertEqual(Status.FAILED, manager.steps[2].status)106 self.assertIn('Asset administration shell AssetAdministrationShell[Identifier(IRI=https://acplt.org/'107 'Test_AssetAdministrationShell)] must exist in given asset administrationshell list',108 manager.format_step(2, verbose_level=1))109 def test_check_xml_files_equivalence(self) -> None:110 manager = ComplianceToolStateManager()111 script_dir = os.path.dirname(__file__)112 file_path_1 = os.path.join(script_dir, 'files/test_not_deserializable_aas.xml')113 file_path_2 = os.path.join(script_dir, 'files/test_empty.xml')114 compliance_tool.check_xml_files_equivalence(file_path_1, file_path_2, manager)115 self.assertEqual(5, len(manager.steps))116 self.assertEqual(Status.SUCCESS, manager.steps[0].status)117 self.assertEqual(Status.FAILED, manager.steps[1].status)118 self.assertEqual(Status.SUCCESS, manager.steps[2].status)119 self.assertEqual(Status.SUCCESS, manager.steps[3].status)120 self.assertEqual(Status.NOT_EXECUTED, manager.steps[4].status)121 manager.steps = []122 compliance_tool.check_xml_files_equivalence(file_path_2, file_path_1, manager)123 self.assertEqual(5, len(manager.steps))124 self.assertEqual(Status.SUCCESS, manager.steps[0].status)125 self.assertEqual(Status.SUCCESS, manager.steps[1].status)126 self.assertEqual(Status.SUCCESS, manager.steps[2].status)127 self.assertEqual(Status.FAILED, manager.steps[3].status)128 self.assertEqual(Status.NOT_EXECUTED, manager.steps[4].status)129 manager.steps = []130 file_path_3 = os.path.join(script_dir, 'files/test_demo_full_example.xml')131 file_path_4 = os.path.join(script_dir, 'files/test_demo_full_example.xml')132 compliance_tool.check_xml_files_equivalence(file_path_3, file_path_4, manager)133 self.assertEqual(5, len(manager.steps))134 self.assertEqual(Status.SUCCESS, manager.steps[0].status)135 self.assertEqual(Status.SUCCESS, manager.steps[1].status)136 self.assertEqual(Status.SUCCESS, manager.steps[2].status)137 self.assertEqual(Status.SUCCESS, manager.steps[3].status)138 self.assertEqual(Status.SUCCESS, manager.steps[4].status)139 manager.steps = []140 file_path_3 = os.path.join(script_dir, 'files/test_demo_full_example.xml')141 file_path_4 = os.path.join(script_dir, 'files/test_demo_full_example_wrong_attribute.xml')142 compliance_tool.check_xml_files_equivalence(file_path_3, file_path_4, manager)143 self.assertEqual(5, len(manager.steps))144 self.assertEqual(Status.SUCCESS, manager.steps[0].status)145 self.assertEqual(Status.SUCCESS, manager.steps[1].status)146 self.assertEqual(Status.SUCCESS, manager.steps[2].status)147 self.assertEqual(Status.SUCCESS, manager.steps[3].status)148 self.assertEqual(Status.FAILED, manager.steps[4].status)149 manager.steps = []150 compliance_tool.check_xml_files_equivalence(file_path_4, file_path_3, manager)151 self.assertEqual(5, len(manager.steps))152 self.assertEqual(Status.SUCCESS, manager.steps[0].status)153 self.assertEqual(Status.SUCCESS, manager.steps[1].status)154 self.assertEqual(Status.SUCCESS, manager.steps[2].status)155 self.assertEqual(Status.SUCCESS, manager.steps[3].status)156 self.assertEqual(Status.FAILED, manager.steps[4].status)157 self.assertIn('Asset administration shell AssetAdministrationShell[Identifier(IRI=https://acplt.org/'158 'Test_AssetAdministrationShell)] must exist in given asset administrationshell list',...
test_history.py
Source:test_history.py
...31 self.assertEqual(h["loss"].data[0], h2["loss"].data[0])32 self.assertEqual(h["accuracy"].data[0], h2["accuracy"].data[0])33 self.assertEqual(h2.step, 99)34 self.assertEqual(h2.metrics, {"loss", "accuracy"})35 self.assertEqual(hl.history.format_step(h2.step), "99")36 self.assertEqual(hl.history.format_step(h2.step, zero_prefix=True), "000099")37 # Clean up38 shutil.rmtree(OUTPUT_DIR)39 def test_epochs(self):40 # Create History object41 h = hl.History()42 for e in range(10):43 for s in range(100):44 loss = (100-s)/10045 accuracy = s / 10046 h.log((e, s), loss=loss)47 h.log((e, s), accuracy=accuracy)48 self.assertEqual(h["loss"].data[0], 1)49 self.assertEqual(h["accuracy"].data[0], 0)50 # Save and load51 if not os.path.exists(OUTPUT_DIR):52 os.makedirs(OUTPUT_DIR)53 h.save(os.path.join(OUTPUT_DIR, "history_epoch.pkl"))54 55 # Load it56 h2 = hl.History()57 h2.load(os.path.join(OUTPUT_DIR, "history_epoch.pkl"))58 self.assertEqual(h["loss"].data[0], h2["loss"].data[0])59 self.assertEqual(h["accuracy"].data[0], h2["accuracy"].data[0])60 self.assertEqual(h2.step, (9, 99))61 self.assertEqual(h2.metrics, {"loss", "accuracy"})62 self.assertEqual(hl.history.format_step(h2.step), "9:99")63 self.assertEqual(hl.history.format_step(h2.step, zero_prefix=True), "0009:000099")64 # Clean up65 shutil.rmtree(OUTPUT_DIR)66if __name__ == "__main__":...
test_state_manager.py
Source:test_state_manager.py
...28 checker = DataChecker(raise_immediately=False)29 checker.check(2 == 2, 'Assertion test')30 manager.add_log_records_from_data_checker(checker)31 self.assertEqual(0, len(manager.get_error_logs_from_step(1)))32 self.assertEqual('SUCCESS: test 2', manager.format_step(1, 1))33 self.assertEqual('SUCCESS: test 2', manager.format_step(1, 1))34 self.assertIn('INFO: Assertion test ()', manager.format_step(1, 2))35 checker.check(2 == 1, 'Assertion test 2')36 manager.add_log_records_from_data_checker(checker)37 self.assertEqual(1, len(manager.get_error_logs_from_step(1)))38 self.assertEqual('FAILED: test 2', manager.format_step(1))39 self.assertIn('ERROR: Assertion test 2 ()', manager.format_step(1, 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!!