def test_from_joystick(self): for i in range(controller.get_count()): if controller.is_controller(i): joy = pygame.joystick.Joystick(i) break else: self.skipTest("No controller connected") c = controller.Controller.from_joystick(joy) self.assertIsInstance(c, controller.Controller)
def test_is_controller(self): for i in range(controller.get_count()): if controller.is_controller(i): c = controller.Controller(i) self.assertIsInstance(c, controller.Controller) c.quit() else: with self.assertRaises(pygame._sdl2.sdl2.error): c = controller.Controller(i) with self.assertRaises(TypeError): controller.is_controller('Test')
def test__get_count_interactive(self): prompt("Please connect at least one controller " "before the test for controller.get_count() starts") # Reset the number of joysticks counted controller.quit() controller.init() joystick_num = controller.get_count() ans = question("get_count() thinks there are {} joysticks " "connected. Is that correct?".format(joystick_num)) self.assertTrue(ans)
def _get_first_controller(self): for i in range(controller.get_count()): if controller.is_controller(i): return controller.Controller(i)
def test_get_count(self): self.assertGreaterEqual(controller.get_count(), 0)