def test_args_parser(self): with self.assertRaises(SystemExit): with patch('sys.argv', ["hobeta.py", "-h", "-v"]): hobeta.main() with self.assertRaises(SystemExit): with patch('sys.argv', ["hobeta.py"]): hobeta.main() with patch('sys.argv', ["hobeta.py", "hobeta-help"]): hobeta.main() args_parser = hobeta.create_parser() temp_in_file = tempfile.mkstemp()[1] input_file = open(temp_in_file, "w") input_file.close() temp_out_file = tempfile.mkstemp()[1] try: args = safe_parse_args(args_parser, ["info", temp_in_file]) self.assertEqual(args.func, hobeta.show_info) args.hobeta_file.close() args = safe_parse_args(args_parser, ["strip", temp_in_file, temp_out_file]) self.assertEqual(args.func, hobeta.strip_header) args.hobeta_file.close() args.output_file.close() finally: os.remove(temp_in_file) os.remove(temp_out_file)
def test_args_parser(self): args_parser = zeus2txt.create_parser() with self.assertRaises(SystemExit): with patch('sys.argv', ["zeus2txt.py", "-h", "-v"]): zeus2txt.main() with self.assertRaises(SystemExit): with patch('sys.argv', ["zeus2txt.py"]): zeus2txt.main() temp_in_file = tempfile.mkstemp()[1] input_file = open(temp_in_file, "w") input_file.close() temp_out_file = tempfile.mkstemp()[1] try: args = safe_parse_args(args_parser, ["info", temp_in_file]) self.assertEqual(args.func, zeus2txt.show_info) args.zeus_file.close() args = safe_parse_args(args_parser, ["convert", temp_in_file, temp_out_file]) self.assertEqual(args.func, zeus2txt.convert_file) args.zeus_file.close() args.output_file.close() finally: os.remove(temp_in_file) os.remove(temp_out_file)