From patchwork Fri Dec 1 14:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lussier-Cullen X-Patchwork-Id: 35574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E519DC4167B for ; Fri, 1 Dec 2023 14:48:59 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.1233.1701442134226344646 for ; Fri, 01 Dec 2023 06:48:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=mi/KTJS9; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alexander.lussier-cullen@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id A6CAF9C094E; Fri, 1 Dec 2023 09:48:52 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id Bz0GJ_Swci3R; Fri, 1 Dec 2023 09:48:52 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 1FA3E9C095B; Fri, 1 Dec 2023 09:48:52 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 1FA3E9C095B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1701442132; bh=SZ9PU0D6g2w8CLov827ScBWFUHFpKOeFxN6mubDE/AM=; h=From:To:Date:Message-Id:MIME-Version; b=mi/KTJS9g2n+rjfuxu80hGu5GRru7JJWxWA8pge2DtTMX7PyLFCupxaSG29zF0rC2 6qHjNOx+P+j4LW+/vXJ5qB3CK6V1Tl6XGkHIJk80Mt4zTyfRnhdPeBb05viggyXubw RIwZPxxXO5Chrqaz5yjZ/UwjcUEN4U6ifDk4wGiMxM6Se5LX7Hi6lmZKltTFiFGSn3 N7oxA644oAd6kwHvRsuqgurwUPpegbclYEjs5DVfImbxjQDUqiwK2AUsXbCWCJZb99 PqHWHbLAXJBvMIW8FdN4mAlxgEzeg/zmnbW8WRMxqpzNMdOtnSnTZy98kYXEXr5ZwU YbWdtIhYEHHOw== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id Qj_e4wVBnV3e; Fri, 1 Dec 2023 09:48:52 -0500 (EST) Received: from localhost.localdomain (bras-base-mtrlpq427kw-grc-24-184-147-255-35.dsl.bell.ca [184.147.255.35]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 09EC39C094E; Fri, 1 Dec 2023 09:48:52 -0500 (EST) From: Alexander Lussier-Cullen To: toaster@lists.yoctoproject.org Cc: Alexander Lussier-Cullen , Richard Purdie Subject: [Toaster v2] bitbake: toaster: fix pytest build test execution and test discovery Date: Fri, 1 Dec 2023 09:48:33 -0500 Message-Id: <20231201144833.4158-1-alexander.lussier-cullen@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 01 Dec 2023 14:48:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/6043 Ensure the proper django settings are used by moving the variable to the environment assignment. Remove python file specifier as this works relative to the working directory, which can vary. The test file directory can instead be specified when executing the pytest command. Add annotations required to allow database access with pytest to the build tests. Signed-off-by: Alexander Lussier-Cullen CC: Richard Purdie --- bitbake/lib/toaster/pytest.ini | 5 +---- bitbake/lib/toaster/tests/builds/test_core_image_min.py | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bitbake/lib/toaster/pytest.ini b/bitbake/lib/toaster/pytest.ini index f07076b7ea..071c65fcd5 100644 --- a/bitbake/lib/toaster/pytest.ini +++ b/bitbake/lib/toaster/pytest.ini @@ -1,9 +1,5 @@ # -- FILE: pytest.ini (or tox.ini) [pytest] -DJANGO_SETTINGS_MODULE = toastermain.settings_test - -python_files = db/test_*.py commands/test_*.py views/test_*.py browser/test_*.py functional/test_*.py - # --create-db - force re creation of the test database # https://pytest-django.readthedocs.io/en/latest/database.html#create-db-force-re-creation-of-the-test-database @@ -17,3 +13,4 @@ addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html # https://pypi.org/project/pytest-env/ env = TOASTER_BUILDSERVER=1 + DJANGO_SETTINGS_MODULE=toastermain.settings_test diff --git a/bitbake/lib/toaster/tests/builds/test_core_image_min.py b/bitbake/lib/toaster/tests/builds/test_core_image_min.py index 9cdaa15f98..ca388eabe7 100644 --- a/bitbake/lib/toaster/tests/builds/test_core_image_min.py +++ b/bitbake/lib/toaster/tests/builds/test_core_image_min.py @@ -10,6 +10,7 @@ # Ionut Chisanovici, Paul Eggleton and Cristian Iorga import os +import pytest from django.db.models import Q @@ -21,6 +22,7 @@ from orm.models import CustomImagePackage from tests.builds.buildtest import BuildTest +@pytest.mark.django_db(True) class BuildCoreImageMinimal(BuildTest): """Build core-image-minimal and test the results"""