py: unittests: Make typechecker happy
Add some annotations and self.assertIsNotNone() calls to remove the typechecker warnings. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
518f46ff0f
commit
7ac7e0e119
1 changed files with 11 additions and 2 deletions
|
@ -10,6 +10,7 @@ import libcamera as libcam
|
||||||
import os
|
import os
|
||||||
import selectors
|
import selectors
|
||||||
import time
|
import time
|
||||||
|
import typing
|
||||||
import unittest
|
import unittest
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
|
@ -70,6 +71,9 @@ class SimpleTestMethods(BaseTestCase):
|
||||||
|
|
||||||
|
|
||||||
class CameraTesterBase(BaseTestCase):
|
class CameraTesterBase(BaseTestCase):
|
||||||
|
cm: typing.Any
|
||||||
|
cam: typing.Any
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.cm = libcam.CameraManager.singleton()
|
self.cm = libcam.CameraManager.singleton()
|
||||||
self.cam = next((cam for cam in self.cm.cameras if 'platform/vimc' in cam.id), None)
|
self.cam = next((cam for cam in self.cm.cameras if 'platform/vimc' in cam.id), None)
|
||||||
|
@ -131,6 +135,7 @@ class AllocatorTestMethods(CameraTesterBase):
|
||||||
wr_allocator = weakref.ref(allocator)
|
wr_allocator = weakref.ref(allocator)
|
||||||
|
|
||||||
buffers = allocator.buffers(stream)
|
buffers = allocator.buffers(stream)
|
||||||
|
self.assertIsNotNone(buffers)
|
||||||
buffers = None
|
buffers = None
|
||||||
|
|
||||||
buffer = allocator.buffers(stream)[0]
|
buffer = allocator.buffers(stream)[0]
|
||||||
|
@ -166,6 +171,8 @@ class SimpleCaptureMethods(CameraTesterBase):
|
||||||
|
|
||||||
streamconfig = camconfig.at(0)
|
streamconfig = camconfig.at(0)
|
||||||
fmts = streamconfig.formats
|
fmts = streamconfig.formats
|
||||||
|
self.assertIsNotNone(fmts)
|
||||||
|
fmts = None
|
||||||
|
|
||||||
ret = cam.configure(camconfig)
|
ret = cam.configure(camconfig)
|
||||||
self.assertZero(ret)
|
self.assertZero(ret)
|
||||||
|
@ -225,6 +232,8 @@ class SimpleCaptureMethods(CameraTesterBase):
|
||||||
|
|
||||||
streamconfig = camconfig.at(0)
|
streamconfig = camconfig.at(0)
|
||||||
fmts = streamconfig.formats
|
fmts = streamconfig.formats
|
||||||
|
self.assertIsNotNone(fmts)
|
||||||
|
fmts = None
|
||||||
|
|
||||||
ret = cam.configure(camconfig)
|
ret = cam.configure(camconfig)
|
||||||
self.assertZero(ret)
|
self.assertZero(ret)
|
||||||
|
@ -348,9 +357,9 @@ if __name__ == '__main__':
|
||||||
gc.unfreeze()
|
gc.unfreeze()
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
obs_after = get_all_objects([obs_before])
|
obs_after = get_all_objects([obs_before]) # type: ignore
|
||||||
|
|
||||||
before = create_type_count_map(obs_before)
|
before = create_type_count_map(obs_before) # type: ignore
|
||||||
after = create_type_count_map(obs_after)
|
after = create_type_count_map(obs_after)
|
||||||
|
|
||||||
leaks = diff_type_count_maps(before, after)
|
leaks = diff_type_count_maps(before, after)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue