summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlassane Yattara <alassane.yattara@savoirfairelinux.com>2023-11-09 16:55:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-09 17:01:18 +0000
commit8b957cf1fe1b075adffa5580d3c6ca31efc842e4 (patch)
tree37c36a0168a9cff7f54b96b9fea95b3eb26cbb84
parent5e46a34555d9e823168d3f34388f61dd1bdf8b9a (diff)
downloadpoky-8b957cf1fe1b075adffa5580d3c6ca31efc842e4.tar.gz
bitbake: toaster: fixed: Tests fail when executed one after the other out of sequence
As mentionned in earlier commit, pytest-django takes a conservative approach to enabling database access. By default our tests will fail if they try to access the database, Only if we explicitly request database access will this be allowed, using pytest marks to tell pytest-django our test needs database access. A side effect of pytest mark, is test_case method marked is execute out of scope of its module class, which create an inconsistance sequence and make fails followings tests. The scope of the ordering is global per default, e.g. tests with lower ordinal numbers are always executed before tests with higher numbers in the same test session, regardless of the module and class they reside in. This can be changed by using the --order-scope option from module pytest-order. To fix that i added execution order to tests suite using pytest-order. (Bitbake rev: 8bf32459ab6d8ce7632fca0a4ce0f3aecc7495c2) Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/tests/functional/test_functional_basic.py4
-rw-r--r--bitbake/lib/toaster/tests/toaster-tests-requirements.txt1
-rw-r--r--bitbake/lib/toaster/tests/views/test_views.py2
3 files changed, 6 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_functional_basic.py b/bitbake/lib/toaster/tests/functional/test_functional_basic.py
index 7e9be91ca1..f558cce884 100644
--- a/bitbake/lib/toaster/tests/functional/test_functional_basic.py
+++ b/bitbake/lib/toaster/tests/functional/test_functional_basic.py
@@ -8,12 +8,14 @@
8# 8#
9 9
10import re, time 10import re, time
11import pytest
12from django.urls import reverse 11from django.urls import reverse
12import pytest
13from tests.functional.functional_helpers import SeleniumFunctionalTestCase 13from tests.functional.functional_helpers import SeleniumFunctionalTestCase
14from orm.models import Project 14from orm.models import Project
15from selenium.webdriver.common.by import By 15from selenium.webdriver.common.by import By
16 16
17
18@pytest.mark.order("last")
17class FuntionalTestBasic(SeleniumFunctionalTestCase): 19class FuntionalTestBasic(SeleniumFunctionalTestCase):
18 20
19# testcase (1514) 21# testcase (1514)
diff --git a/bitbake/lib/toaster/tests/toaster-tests-requirements.txt b/bitbake/lib/toaster/tests/toaster-tests-requirements.txt
index 7109c625d2..71cc083436 100644
--- a/bitbake/lib/toaster/tests/toaster-tests-requirements.txt
+++ b/bitbake/lib/toaster/tests/toaster-tests-requirements.txt
@@ -4,3 +4,4 @@ pytest-django==4.5.2
4pytest-env==1.1.0 4pytest-env==1.1.0
5pytest-html==4.0.2 5pytest-html==4.0.2
6pytest-metadata==3.0.0 6pytest-metadata==3.0.0
7pytest-order==1.1.0
diff --git a/bitbake/lib/toaster/tests/views/test_views.py b/bitbake/lib/toaster/tests/views/test_views.py
index 06bf6c20a3..349881ebf6 100644
--- a/bitbake/lib/toaster/tests/views/test_views.py
+++ b/bitbake/lib/toaster/tests/views/test_views.py
@@ -9,6 +9,7 @@
9 9
10"""Test cases for Toaster GUI and ReST.""" 10"""Test cases for Toaster GUI and ReST."""
11 11
12import pytest
12from django.test import TestCase 13from django.test import TestCase
13from django.test.client import RequestFactory 14from django.test.client import RequestFactory
14from django.urls import reverse 15from django.urls import reverse
@@ -33,6 +34,7 @@ PROJECT_NAME2 = "test project 2"
33CLI_BUILDS_PROJECT_NAME = 'Command line builds' 34CLI_BUILDS_PROJECT_NAME = 'Command line builds'
34 35
35 36
37@pytest.mark.order(1)
36class ViewTests(TestCase): 38class ViewTests(TestCase):
37 """Tests to verify view APIs.""" 39 """Tests to verify view APIs."""
38 40