Message ID | 20231030195037.232912-4-alassane.yattara@savoirfairelinux.com |
---|---|
State | New |
Headers | show |
Series | [1/8] Toaster: Update toaster-requirements.txt to add pytest and some plugin's | expand |
On Mon, Oct 30, 2023 at 12:51 PM Alassane Yattara < alassane.yattara@savoirfairelinux.com> wrote: > Pytest failed on functional/test_functional_basic because database access > not allowed > - we should use "django_db" fixture to allowed db access > > Note: Pytest-django takes a conservative approach to enabling database > access. > By default your tests will fail if they try to access the database. > Only if you explicitly request database access will this be allowed. > > We're missing an opportunity to add a link to pytest.mark.django_db documentation: https://pytest-django.readthedocs.io/en/latest/helpers.html#pytest-mark-django-db-request-database-access This makes it easier for someone to review the change and for someone in the future to understand what it does. Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> > --- > lib/toaster/tests/functional/test_functional_basic.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/toaster/tests/functional/test_functional_basic.py > b/lib/toaster/tests/functional/test_functional_basic.py > index b0def544..7e9be91c 100644 > --- a/lib/toaster/tests/functional/test_functional_basic.py > +++ b/lib/toaster/tests/functional/test_functional_basic.py > @@ -8,6 +8,7 @@ > # > > import re, time > +import pytest > from django.urls import reverse > from tests.functional.functional_helpers import SeleniumFunctionalTestCase > from orm.models import Project > @@ -16,6 +17,7 @@ from selenium.webdriver.common.by import By > class FuntionalTestBasic(SeleniumFunctionalTestCase): > > # testcase (1514) > + @pytest.mark.django_db > def test_create_slenium_project(self): > This would be a great opportunity to fix the typo in the test name slenium -> selenium > project_name = 'selenium-project' > self.get(reverse('newproject')) > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#15328): > https://lists.openembedded.org/g/bitbake-devel/message/15328 > Mute This Topic: https://lists.openembedded.org/mt/102283460/924729 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ > ticotimo@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
diff --git a/lib/toaster/tests/functional/test_functional_basic.py b/lib/toaster/tests/functional/test_functional_basic.py index b0def544..7e9be91c 100644 --- a/lib/toaster/tests/functional/test_functional_basic.py +++ b/lib/toaster/tests/functional/test_functional_basic.py @@ -8,6 +8,7 @@ # import re, time +import pytest from django.urls import reverse from tests.functional.functional_helpers import SeleniumFunctionalTestCase from orm.models import Project @@ -16,6 +17,7 @@ from selenium.webdriver.common.by import By class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1514) + @pytest.mark.django_db def test_create_slenium_project(self): project_name = 'selenium-project' self.get(reverse('newproject'))
Pytest failed on functional/test_functional_basic because database access not allowed - we should use "django_db" fixture to allowed db access Note: Pytest-django takes a conservative approach to enabling database access. By default your tests will fail if they try to access the database. Only if you explicitly request database access will this be allowed. Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> --- lib/toaster/tests/functional/test_functional_basic.py | 2 ++ 1 file changed, 2 insertions(+)