def test_export_namespace(self): try: os.remove('/tmp/level.png') except: pass self.assertFileNotExists('/tmp/level.png') image.export_nametable( 'fixtures/nerdynights/scrolling/SMBlevel.bin', 'fixtures/nerdynights/scrolling/mario.chr', '/tmp/level.png') self.assertFileExists('/tmp/level.png') img = Image.open('/tmp/level.png') sprs, indexes = image.acquire_chr(img, optimize_repeated=False) sprite.length(sprs) self.assertEquals(1024, sprite.length(sprs)) return # TODO why?! nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin') nt = nt_file.read() nt_file.close() nts = [ord(n) for n in nt] mario = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr') for i in range(32): for j in range(32): self.assertSpriteEquals( sprite.get_sprite(nts[i * j] + 256, mario), sprite.get_sprite(i * j, sprs) ) os.remove('/tmp/level.png')
def test_export_namespace(self): try: os.remove('/tmp/level.png') except: pass self.assertFileNotExists('/tmp/level.png') image.export_nametable( 'fixtures/nerdynights/scrolling/SMBlevel.bin', 'fixtures/nerdynights/scrolling/mario.chr', '/tmp/level.png') self.assertFileExists('/tmp/level.png') img = Image.open('/tmp/level.png') sprs, indexes = image.acquire_chr(img, optimize_repeated=False) sprite.length(sprs) self.assertEquals(1024,sprite.length(sprs)) return #TODO why?! nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin') nt = nt_file.read() nt_file.close() nts = [ord(n) for n in nt] mario = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr') for i in range(32): for j in range(32): self.assertSpriteEquals( sprite.get_sprite(nts[i*j] + 256, mario), sprite.get_sprite(i*j, sprs) ) os.remove('/tmp/level.png')
def test_export_chr(self): try: os.remove('/tmp/mario.png') except: pass self.assertFileNotExists('/tmp/mario.png') image.export_chr('fixtures/nerdynights/scrolling/mario.chr', '/tmp/mario.png') self.assertFileExists('/tmp/mario.png') self.assertPNGFileEquals('fixtures/mario.png', '/tmp/mario.png') img = Image.open('/tmp/mario.png') sprs, indexes = image.acquire_chr(img) self.assertIsNotNone(sprs) self.assertEquals(8192, len(sprs)) self.assertSpriteEquals(self.mario1, sprite.get_sprite(0, sprs)) self.assertSpriteEquals(self.mario2, sprite.get_sprite(1, sprs)) os.remove('/tmp/mario.png')
def test_acquire_chr(self): img = Image.open('fixtures/mario.png') sprs, indexes = image.acquire_chr(img) self.assertEquals(8192, len(sprs)) self.assertSpriteEquals(self.mario1, sprite.get_sprite(0, sprs))