def test_error_file_not_found(self): command_parser_python.read_and_process("..\\test-files\\xxxx.txt") output = sys.stdout.getvalue().strip() self.assertEqual(output, 'Exception opening/reading/closing file')
def test_error_07(self): command_parser_python.read_and_process( "..\\test-files\\test_error_07.txt") output = sys.stdout.getvalue().strip() self.assertEqual(output, 'Line:4:Error variable not found')
def test_07(self): command_parser_python.read_and_process("..\\test-files\\test_07.txt") output = sys.stdout.getvalue().strip() self.assertEqual(output, '50')
def test_error_02(self): command_parser_python.read_and_process( "..\\test-files\\test_error_02.txt") output = sys.stdout.getvalue().strip() self.assertEqual(output, 'Line:1:Error variable value overflow')
import sys from command_parser_python import read_and_process EXIT_SUCCESS = 0 EXIT_ERROR = 1 ret = EXIT_SUCCESS if len(sys.argv) != 2: print("File name not found!\nPlease use: python main.py test.txt") exit(EXIT_ERROR) filename = sys.argv[1] try: ret = read_and_process(filename) except Exception as ex: print(ex) ret = EXIT_ERROR exit(ret)