Ejemplo n.º 1
0
    def test_screen_draw(self):
        """Compare current screen with past screenshot"""
        w = self.w
        g = self.__class__.g
        w.draw()
        g.blit_consoles(self.status_bar_mock)
        self.console_flush()

        with tempfile.NamedTemporaryFile() as my_tempfile:
            libtcod.sys_save_screenshot(my_tempfile.name)
            dynamic_img = Image.open(my_tempfile.name)
            old_img = Image.open(SCREENSHOT_TEST_PATH)
            rms = img_rms_diff(old_img, dynamic_img)
            self.assertEqual(rms, 0)
            self.assertEqual(dynamic_img.tobytes(), old_img.tobytes())
Ejemplo n.º 2
0
    def test_screen_movement(self):
        player = self.player
        start_block = self.start_block
        w = self.w
        g = self.__class__.g

        a = actions.Move()
        a.dir_dict['right'] = True
        a.dir('right', (player.x+1, player.y), start_block, player)

        w.draw()
        g.blit_consoles(self.status_bar_mock)
        self.console_flush()

        with tempfile.NamedTemporaryFile() as my_tempfile:
            libtcod.sys_save_screenshot(my_tempfile.name)
            dynamic_img = Image.open(my_tempfile.name)
            old_img = Image.open(SCREENSHOT_TEST_PATH)
            rms = img_rms_diff(old_img, dynamic_img)
            # Same color content, different positions
            self.assertEqual(rms, 0)
            self.assertNotEqual(dynamic_img.tobytes(), old_img.tobytes())