def test_load(self): stdout = StringIO() mon = Monitor(stdout=stdout) f = tempfile.NamedTemporaryFile() f.write(chr(0xAA) + chr(0xBB) + chr(0xCC)) f.flush() mon.do_load("'%s' a600" % f.name) self.assertEqual([0xAA, 0xBB, 0xCC], mon._mpu.memory[0xA600:0xA603]) self.assertEqual('Wrote +3 bytes from $a600 to $a602\n', stdout.getvalue()) f.close()
def test_load(self): stdout = StringIO() mon = Monitor(stdout=stdout) f = tempfile.NamedTemporaryFile() f.write(b'\xaa\xbb\xcc') f.flush() mon.do_load("'%s' a600" % f.name) self.assertEqual([0xAA, 0xBB, 0xCC], mon._mpu.memory[0xA600:0xA603]) self.assertEqual('Wrote +3 bytes from $a600 to $a602\n', stdout.getvalue()) f.close()
def test_load(self): stdout = StringIO() mon = Monitor(stdout=stdout) filename = tempfile.mktemp() try: f = open(filename, "wb") f.write(b"\xaa\xbb\xcc") f.close() mon.do_load("'%s' a600" % filename) self.assertEqual("Wrote +3 bytes from $a600 to $a602\n", stdout.getvalue()) self.assertEqual([0xAA, 0xBB, 0xCC], mon._mpu.memory[0xA600:0xA603]) finally: os.unlink(filename)
def test_load(self): stdout = StringIO() mon = Monitor(stdout=stdout) filename = tempfile.mktemp() try: f = open(filename, 'wb') f.write(chr(0xAA) + chr(0xBB) + chr(0xCC)) f.close() mon.do_load("'%s' a600" % filename) self.assertEqual('Wrote +3 bytes from $a600 to $a602\n', stdout.getvalue()) self.assertEqual([0xAA, 0xBB, 0xCC], mon._mpu.memory[0xA600:0xA603]) finally: os.unlink(filename)
def test_load_with_more_than_two_args_syntax_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_load('one two three') out = stdout.getvalue() self.assertTrue(out.startswith('Syntax error'))