toaster.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [Toaster v2] bitbake: toaster: fix pytest build test execution and test discovery
@ 2023-12-01 14:48 Alexander Lussier-Cullen
  2023-12-02 18:05 ` Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lussier-Cullen @ 2023-12-01 14:48 UTC (permalink / raw)
  To: toaster; +Cc: Alexander Lussier-Cullen, Richard Purdie

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 <alexander.lussier-cullen@savoirfairelinux.com>
CC: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 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"""
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Toaster v2] bitbake: toaster: fix pytest build test execution and test discovery
  2023-12-01 14:48 [Toaster v2] bitbake: toaster: fix pytest build test execution and test discovery Alexander Lussier-Cullen
@ 2023-12-02 18:05 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2023-12-02 18:05 UTC (permalink / raw)
  To: Alexander Lussier-Cullen, toaster

On Fri, 2023-12-01 at 09:48 -0500, Alexander Lussier-Cullen wrote:
> 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 <alexander.lussier-cullen@savoirfairelinux.com>
> CC: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  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"""
>  

This and the helper patch don't seem to work so well:

https://autobuilder.yoctoproject.org/typhoon/#/builders/161/builds/16/steps/11/logs/stdio

Cheers,

Richard


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-02 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01 14:48 [Toaster v2] bitbake: toaster: fix pytest build test execution and test discovery Alexander Lussier-Cullen
2023-12-02 18:05 ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).