相关疑难解决方法(0)

Django单元测试; 使用python-social-auth登录

我想为使用python-social-auth的 Django应用程序编写单元测试.运行Django并使用浏览器时,这一切都很棒,感谢python-social-auth!

但是,我似乎无法编写单元测试,因为我无法创建经过身份验证的客户端进行测试.

有没有人这么成功?
你是如何获得经过身份验证的客户端()的?

我试过这个(登录返回false并且不起作用):

self.c = Client()
self.u = User.objects.create(username="testuser", password="password", is_staff=True, is_active=True, is_superuser=True)
self.u.save()
self.auth = UserSocialAuth(user=self.u, provider="Facebook")
self.auth.save()
self.c.login(username=self.u.username, password=self.u.password) 
Run Code Online (Sandbox Code Playgroud)

python django unit-testing oauth django-authentication

2
推荐指数
1
解决办法
1737
查看次数