From patchwork Tue May 17 14:33:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15930 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 85F13C326E for ; Tue, 17 May 2022 14:33:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 90BB56150E; Tue, 17 May 2022 16:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652798038; bh=CtW1NDm3DIh/r1HdoChtqD1UBdwwy7iA9E7BTzTyYPc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mOcxJ+z1pOelE0D8XdcFogY0gLn/k7IhTe3SF1PQ08vCKVDC4Bgt+Xj3fK6u3r4RK r14mQkz0MJYQniWLKUuh2zerM4CK2kx7+VEVTkZnBnUcmMDUv+DjqitKujgI+dtp4q 7Dsa/nhSBi3KKJHUxGlhpuJ+aPH5d0pXSROQhdrR1AC4zBW6tJqTT6nL+Yi3tLeiPq ZG5uixoi6lUa2Sd1/E+t/+ZI7lHdFOJpReMfVWZtVjU/iQ4ug5U9K8JJO07m9xVczf qcsUYT2VFUn+YnCclivxueqljfy6Q0NDo1T4Rum+Ks5LSjhOXUu8XMWMzcKymXdDj6 UJWHGbqlk0/jw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4CB065665 for ; Tue, 17 May 2022 16:33:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YWja2Eoe"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B80DDA8; Tue, 17 May 2022 16:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652798034; bh=CtW1NDm3DIh/r1HdoChtqD1UBdwwy7iA9E7BTzTyYPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YWja2EoeCoBcw/puNHr9uBSPP9CAaBSV+JwwZXViNUXSaKZfkriTvUK4VdH3Jpsj3 VhPoXEkSYNBlk8fHC5zlKL/GFWlGhASK93NfB3J0rUE8di94ULLzmrappHRxesrx+a FvBEpp4DRFMocg9d/tfr1RZwQaoiQt8RkQvFgnmM= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Tue, 17 May 2022 17:33:18 +0300 Message-Id: <20220517143325.71784-7-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220517143325.71784-1-tomi.valkeinen@ideasonboard.com> References: <20220517143325.71784-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/13] py: unittests: make typechecker happy X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add some annotations and self.assertIsNotNone() calls to remove the typechecker warnings. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/py/unittests.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/py/unittests.py b/test/py/unittests.py index 4c214f0a..2ea5ca35 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,6 +135,7 @@ class AllocatorTestMethods(CameraTesterBase): wr_allocator = weakref.ref(allocator) buffers = allocator.buffers(stream) + self.assertIsNotNone(buffers) buffers = None buffer = allocator.buffers(stream)[0] @@ -166,6 +171,8 @@ class SimpleCaptureMethods(CameraTesterBase): streamconfig = camconfig.at(0) fmts = streamconfig.formats + self.assertIsNotNone(fmts) + fmts = None ret = cam.configure(camconfig) self.assertZero(ret) @@ -225,6 +232,7 @@ class SimpleCaptureMethods(CameraTesterBase): streamconfig = camconfig.at(0) fmts = streamconfig.formats + self.assertIsNotNone(fmts) ret = cam.configure(camconfig) self.assertZero(ret) @@ -348,9 +356,9 @@ if __name__ == '__main__': gc.unfreeze() 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) leaks = diff_type_count_maps(before, after)