Test client not logged in

I’m working on adding a multiple-database test for ticket #16281.

The test is for hitting an admin URL - I’m creating a user, logging the test client in, but then the view sees the request as from an anonymous user when I call response = self.client.get(<url>, follow=True).

I get the same result whether I call result = self.client.login(username='super', password='secret') or self.client.force_login(user). I can see the session cookie in self.client.cookies, but then the view still sees the user as anonymous.

Any suggestions?

OK, I see what’s going on here - the database router for the test was set to read session information from the “other” database, but write to the “default” database. Once I fixed the router to read sessions from the “default” database, the login worked.