def test_no_eof(self): args, temp_output_path, temp_output_file = self.prepare_convert_args( b"\x0A\x00\x0A\x06\x82\x87\x2C\x34\x32\x00") try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "r") lines = temp_output_file.read().splitlines() self.assertEqual(lines, ["00010 ADD BC,42", ]) finally: temp_output_file.close() os.remove(temp_output_path)
def test_undefined_token(self): logging.basicConfig(level=logging.DEBUG) args, temp_output_path, temp_output_file = self.prepare_convert_args( b"\x0A\x00\x0A\x06\xFF\x2C\x34\x32\x00\xFF\xFF") try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "r") lines = temp_output_file.read().splitlines() self.assertEqual(lines, ["00010 ,42", ""]) finally: temp_output_file.close() os.remove(temp_output_path)
def test_convert(self): args, temp_output_path, temp_output_file = self.prepare_convert_args( self.test_data) try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "rb") lines = temp_output_file.read().splitlines() expected_lines = self.test_output.split(b"\n") self.assertEqual(lines, expected_lines) finally: temp_output_file.close() os.remove(temp_output_path)
def test_no_eof(self): args, temp_output_path, temp_output_file = self.prepare_convert_args( b"\x0A\x00\x0A\x06\x82\x87\x2C\x34\x32\x00") try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "r") lines = temp_output_file.read().splitlines() self.assertEqual(lines, [ "00010 ADD BC,42", ]) finally: temp_output_file.close() os.remove(temp_output_path)
def test_include_code(self): args, temp_output_path, temp_output_file = self.prepare_convert_args( b"\x0A\x00\x0A\x06\x82\x87\x2C\x34\x32\x00", True) try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "r") lines = temp_output_file.read().splitlines() self.assertEqual(lines, ["00010 ADD BC,42" " ; 0x000A " "0x0A 0x06 0x82 0x87 " "0x2C 0x34 0x32 0x00 ", ]) finally: temp_output_file.close() os.remove(temp_output_path)
def test_include_code(self): args, temp_output_path, temp_output_file = self.prepare_convert_args( b"\x0A\x00\x0A\x06\x82\x87\x2C\x34\x32\x00", True) try: zeus2txt.convert_file(args) temp_output_file.close() temp_output_file = open(temp_output_path, "r") lines = temp_output_file.read().splitlines() self.assertEqual(lines, [ "00010 ADD BC,42" " ; 0x000A " "0x0A 0x06 0x82 0x87 " "0x2C 0x34 0x32 0x00 ", ]) finally: temp_output_file.close() os.remove(temp_output_path)