asteroids/venv/lib/python3.11/site-packages/pygame/tests/camera_test.py
Florian Schmitt 2e5df21095 first commit
2024-10-08 15:38:46 +03:00

35 lines
801 B
Python

import unittest
import os
import pygame
import pygame.camera
class CameraModuleTest(unittest.TestCase):
def setUp(self):
pygame.init()
pygame.camera.init()
@unittest.skipIf(
os.environ.get("SDL_VIDEODRIVER") in ["dummy", "android"],
"requires the SDL_VIDEODRIVER to be non dummy",
)
def test_camera(self):
cameras = pygame.camera.list_cameras()
if len(cameras) == 0:
self.skipTest("No cameras found")
cam = pygame.camera.Camera(cameras[0], (640, 480))
cam.start()
image = cam.get_image()
self.assertIsNotNone(image, "Could not capture image")
cam.stop()
def tearDown(self):
pygame.camera.quit()
pygame.quit()
if __name__ == "__main__":
unittest.main()