[libcamera-devel] [PATCH 06/14] py: unittests: make typechecker happy

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Tue May 17 10:21:39 CEST 2022


On 17/05/2022 11:19, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Mon, May 16, 2022 at 05:10:14PM +0300, Tomi Valkeinen wrote:
>> Add some annotations to reduce the typechecker warnings.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
>> ---
>>   test/py/unittests.py | 17 +++++++++++------
>>   1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/test/py/unittests.py b/test/py/unittests.py
>> index 288dcd48..e5591f3f 100755
>> --- a/test/py/unittests.py
>> +++ b/test/py/unittests.py
>> @@ -10,6 +10,7 @@ import libcamera as libcam
>>   import os
>>   import selectors
>>   import time
>> +import typing
>>   import unittest
>>   import weakref
>>   
>> @@ -70,6 +71,9 @@ class SimpleTestMethods(BaseTestCase):
>>   
>>   
>>   class CameraTesterBase(BaseTestCase):
>> +    cm: typing.Any
>> +    cam: typing.Any
>> +
>>       def setUp(self):
>>           self.cm = libcam.CameraManager.singleton()
>>           self.cam = next((cam for cam in self.cm.cameras if 'platform/vimc' in cam.id), None)
>> @@ -131,8 +135,8 @@ class AllocatorTestMethods(CameraTesterBase):
>>           self.assertTrue(ret > 0)
>>           wr_allocator = weakref.ref(allocator)
>>   
>> -        buffers = allocator.buffers(stream)
>> -        buffers = None
>> +        buffers = allocator.buffers(stream)     # type: ignore
>> +        buffers = None                          # type: ignore
>>   
>>           buffer = allocator.buffers(stream)[0]
>>           self.assertIsNotNone(buffer)
>> @@ -166,7 +170,8 @@ class SimpleCaptureMethods(CameraTesterBase):
>>           self.assertTrue(camconfig.size == 1)
>>   
>>           streamconfig = camconfig.at(0)
>> -        fmts = streamconfig.formats
>> +        fmts = streamconfig.formats     # type: ignore
>> +        fmts = None                     # type: ignore
> 
> Was this intended ? Actually, fmts doesn't seem to be used at all.

Yes. It's a test. I want to get formats and see that it gets released 
(or rather, the whole object chain gets released in the end, and we 
observe that camera & cam manager gets released).

  Tomi


More information about the libcamera-devel mailing list