Opened 8 years ago

Last modified 8 years ago

#27117 closed Bug

The force_login() does not work in a testing if using more one a test — at Initial Version

Reported by: Seti Owned by: nobody
Component: Testing framework Version: 1.9
Severity: Normal Keywords: Pytest, LiveTests
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top