mirror of
https://github.com/mnaberez/py65.git
synced 2024-06-15 04:29:30 +00:00
Fix tests using temporary files on Windows
This commit is contained in:
parent
d86398e8f9
commit
72df56db53
|
@ -1184,32 +1184,36 @@ class MonitorTests(unittest.TestCase):
|
||||||
self.assertEqual(0xc002, mon._mpu.pc)
|
self.assertEqual(0xc002, mon._mpu.pc)
|
||||||
|
|
||||||
def test_argv_load(self):
|
def test_argv_load(self):
|
||||||
with tempfile.NamedTemporaryFile('wb+') as f:
|
try:
|
||||||
data = bytearray([0xab, 0xcd])
|
with tempfile.NamedTemporaryFile('wb+', delete=False) as f:
|
||||||
f.write(data)
|
data = bytearray([0xab, 0xcd])
|
||||||
f.flush()
|
f.write(data)
|
||||||
|
|
||||||
argv = ['py65mon', '--load', f.name]
|
argv = ['py65mon', '--load', f.name]
|
||||||
stdout = StringIO()
|
stdout = StringIO()
|
||||||
mon = Monitor(argv=argv, stdout=stdout)
|
mon = Monitor(argv=argv, stdout=stdout)
|
||||||
self.assertEqual(list(data), mon._mpu.memory[:len(data)])
|
self.assertEqual(list(data), mon._mpu.memory[:len(data)])
|
||||||
|
finally:
|
||||||
|
os.unlink(f.name)
|
||||||
|
|
||||||
def test_argv_rom(self):
|
def test_argv_rom(self):
|
||||||
with tempfile.NamedTemporaryFile('wb+') as f:
|
try:
|
||||||
rom = bytearray(4096)
|
with tempfile.NamedTemporaryFile('wb+', delete=False) as f:
|
||||||
rom[0] = 0xea # f000 nop
|
rom = bytearray(4096)
|
||||||
rom[1] = 0xea # f001 nop
|
rom[0] = 0xea # f000 nop
|
||||||
rom[2] = 0x00 # f002 brk
|
rom[1] = 0xea # f001 nop
|
||||||
rom[-2] = 0xf000 & 0xff # fffc reset vector low
|
rom[2] = 0x00 # f002 brk
|
||||||
rom[-3] = 0xf000 >> 8 # fffd reset vector high
|
rom[-2] = 0xf000 & 0xff # fffc reset vector low
|
||||||
f.write(rom)
|
rom[-3] = 0xf000 >> 8 # fffd reset vector high
|
||||||
f.flush()
|
f.write(rom)
|
||||||
|
|
||||||
argv = ['py65mon', '--rom', f.name]
|
argv = ['py65mon', '--rom', f.name]
|
||||||
stdout = StringIO()
|
stdout = StringIO()
|
||||||
mon = Monitor(argv=argv, stdout=stdout)
|
mon = Monitor(argv=argv, stdout=stdout)
|
||||||
self.assertEqual(list(rom), mon._mpu.memory[-len(rom):])
|
self.assertEqual(list(rom), mon._mpu.memory[-len(rom):])
|
||||||
self.assertEqual(0xf002, mon._mpu.pc)
|
self.assertEqual(0xf002, mon._mpu.pc)
|
||||||
|
finally:
|
||||||
|
os.unlink(f.name)
|
||||||
|
|
||||||
def test_argv_input(self):
|
def test_argv_input(self):
|
||||||
argv = ['py65mon', '--input', 'abcd']
|
argv = ['py65mon', '--input', 'abcd']
|
||||||
|
@ -1228,15 +1232,15 @@ class MonitorTests(unittest.TestCase):
|
||||||
self.assertTrue('putc' in repr(write_subscribers[0xdcba]))
|
self.assertTrue('putc' in repr(write_subscribers[0xdcba]))
|
||||||
|
|
||||||
def test_argv_combination_rom_mpu(self):
|
def test_argv_combination_rom_mpu(self):
|
||||||
with tempfile.NamedTemporaryFile('wb+') as f:
|
try:
|
||||||
rom = bytearray(4096)
|
with tempfile.NamedTemporaryFile('wb+', delete=False) as f:
|
||||||
rom[0] = 0xea # f000 nop
|
rom = bytearray(4096)
|
||||||
rom[1] = 0xea # f001 nop
|
rom[0] = 0xea # f000 nop
|
||||||
rom[2] = 0x00 # f002 brk
|
rom[1] = 0xea # f001 nop
|
||||||
rom[-2] = 0xf000 & 0xff # fffc reset vector low
|
rom[2] = 0x00 # f002 brk
|
||||||
rom[-3] = 0xf000 >> 8 # fffd reset vector high
|
rom[-2] = 0xf000 & 0xff # fffc reset vector low
|
||||||
f.write(rom)
|
rom[-3] = 0xf000 >> 8 # fffd reset vector high
|
||||||
f.flush()
|
f.write(rom)
|
||||||
|
|
||||||
argv = ['py65mon', '--rom', f.name, '--mpu', '65c02',]
|
argv = ['py65mon', '--rom', f.name, '--mpu', '65c02',]
|
||||||
stdout = StringIO()
|
stdout = StringIO()
|
||||||
|
@ -1244,6 +1248,8 @@ class MonitorTests(unittest.TestCase):
|
||||||
self.assertEqual('65C02', mon._mpu.name)
|
self.assertEqual('65C02', mon._mpu.name)
|
||||||
self.assertEqual(list(rom), mon._mpu.memory[-len(rom):])
|
self.assertEqual(list(rom), mon._mpu.memory[-len(rom):])
|
||||||
self.assertEqual(0xf002, mon._mpu.pc)
|
self.assertEqual(0xf002, mon._mpu.pc)
|
||||||
|
finally:
|
||||||
|
os.unlink(f.name)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.findTestCases(sys.modules[__name__])
|
return unittest.findTestCases(sys.modules[__name__])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user