python - Can I avoid permission_required decorator on Django testing? -


i testing set of django applications make extensive use of 'permission_required' decorator. derives in 302 http response in of views have.

my question is: there way avoid or deactivate 'permission_required' in testing, can 200 response when call views, instead of 302?

thank you!

just log in superuser in test case setup method

 django.test import testcase django.contrib.auth.models import user  class testthatneedslogin(testcase):     def setup(self):         user.objects.create_superuser(             'user1',             'user1@example.com',             'pswd',         )         self.client.login(username="user1", password="pswd")      def teardown(self):         self.client.logout()      def test_something(self):         response = self.client.get("/")         self.assertequal(200, response.status_code) 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -