unit testing - django test redirection fail -


i'm trying write tests view functions , encounter problem.

i want check specific function return me json of kind, i

wrote following code:

client = client() response = client.get('/func/1/true') self.assertredirects(response, "login/?next=/func/1/true", 302) 

when view function is:

@login_required def func(request, objid, flag):     return json.dumps(something) 

but when run tests failed assert:

valueerror: file 'myapp/css/bootstrap.css' not found     <whitenoise.django.gzipmanifeststaticfilesstorage object @ 0x0000000004c7a898>. 

but when run app without tests works find , finds file.

note: run tests eclipse (in case makes different...)

any ideas why happen?

it worked me when disabled whitnoise tests. did disabling stactfiles_storage in settings. can tests @override_settings decorator this:

from django.test import testcase, override_settings django.test import client  class clienttest(testcase):     def setup(self):         self.c = client()      @override_settings(staticfiles_storage = none) # added decorator     def test_client_works(self):         resp = self.c.get('/some/page/')         self.asserttrue(resp.status_code 200)      def teardown(self):         pass 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -