#27117: The force_login() does not work in a testing if using more one a test
-----------------------------------+--------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: Pytest, LiveTests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by setivolkylany):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> # test_.py
>
> {{{
> from django.test import Client
> from django.contrib.auth import get_user_model
> from django.core.management import call_command
> from django.contrib.staticfiles.testing import StaticLiveServerTestCase
>
> class Tests(StaticLiveServerTestCase):
>
> @classmethod
> def setUpClass(cls):
> super(Tests, cls).setUpClass()
>
> call_command('factory_test_superusers', '1')
> cls.active_superuser = get_user_model().objects.get()
>
> def setUp(self):
> c = Client()
> c.force_login(self.active_superuser)
>
> def test_1(self):
> pass
>
> def test_2(self):
> pass
> }}}
>
> # run tests
>
> py.test
>
> traceback is here https://bpaste.net/show/36be7958e3d9
New description:
# test_.py
{{{
from django.test import Client
from django.contrib.auth import get_user_model
from django.core.management import call_command
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
class Tests(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
super(Tests, cls).setUpClass()
# a command for create a superuser for a testing
call_command('factory_test_superusers', '1')
cls.active_superuser = get_user_model().objects.get()
def setUp(self):
c = Client()
c.force_login(self.active_superuser)
def test_1(self):
pass
def test_2(self):
pass
}}}
# run tests
py.test
traceback is here https://bpaste.net/show/36be7958e3d9
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27117#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.238f73b55e06cecd24390657d70cddfe%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.