def readMove(self): """ read and return a move to pass to a board """ k = keypress.getKey() return Game.__dirs.get(k)
def test_getKey_arrow_key_down(self): k = keypress.DOWN self._pushArrowKey(k) self.assertEqual(keypress.getKey(), k)
def test_getKey_arrow_key_up(self): k = keypress.UP self._pushArrowKey(k) self.assertEqual(keypress.getKey(), k)
def test_getKey_read_stdin(self): x = 42 self._pushChars(x) self.assertEqual(keypress.getKey(), x)
def test_getKey_vim_key_right(self): self._pushArrowKey(keypress.L) self.assertEqual(keypress.getKey(), keypress.RIGHT)
def test_getKey_vim_key_left(self): self._pushArrowKey(keypress.H) self.assertEqual(keypress.getKey(), keypress.LEFT)
def test_getKey_arrow_key_right(self): k = keypress.RIGHT self._pushArrowKey(k) self.assertEqual(keypress.getKey(), k)
def test_getKey_vim_key_up(self): self._pushChars(keypress.K) self.assertEqual(keypress.getKey(), keypress.UP)
def test_getKey_arrow_key_left(self): k = keypress.LEFT self._pushArrowKey(k) self.assertEqual(keypress.getKey(), k)
def test_getKey_vim_key_down(self): self._pushArrowKey(keypress.J) self.assertEqual(keypress.getKey(), keypress.DOWN)
def test_termios_fallback_on_msvcrt_getKey(self): self.assertEqual(keypress.getKey(), helpers.msvcrt_key)