#29353: _middleware_chain is not set for StaticFilesHandler
-------------------------------------+-------------------------------------
Reporter: koxu1996 | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: staticfiles | Triage Stage:
middleware_chain | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by koxu1996):
* keywords: static-files testing server => staticfiles middleware_chain
* component: Uncategorized => contrib.staticfiles
Old description:
> I created ''functional_tests'' directory with empty ''__init__.py'' and
> ''test_all.py'' containing following code:
>
> {{{
> from django.test import LiveServerTestCase
> from selenium import webdriver
>
> class DemoTest(LiveServerTestCase):
>
> def test_can_get_empty_list_of_server_seeds(self):
> self.browser = webdriver.Firefox()
>
> print('Before page open')
> self.browser.get(self.live_server_url + '/')
> print('After page open')
>
> self.assertEqual(1, 1)
>
> self.browser.quit()
> }}}
> Running it with 'python manage.py test functional_tests/' result with
> success:
>
> {{{
> ...
> Before page open
> After page open
> .
> ----------------------------------------------------------------------
> Ran 1 test in 7.048s
>
> OK
> ...
> }}}
> But if I change LiveServerTestCase to StaticLiveServerTestCase then I am
> getting strange error:
>
> {{{
> $ python manage.py test functional_tests/
> Creating test database for alias 'default'...
> System check identified no issues (0 silenced).
> Before page open
> Traceback (most recent call last):
> File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
> self.result = application(self.environ, self.start_response)
> File "/usr/lib/python3.6/site-
> packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
> return super().__call__(environ, start_response)
> File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py",
> line 146, in __call__
> response = self.get_response(request)
> File "/usr/lib/python3.6/site-
> packages/django/contrib/staticfiles/handlers.py", line 62, in
> get_response
> return super().get_response(request)
> File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py",
> line 81, in get_response
> response = self._middleware_chain(request)
> TypeError: 'NoneType' object is not callable
> Traceback (most recent call last):
> File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
> self.result = application(self.environ, self.start_response)
> File "/usr/lib/python3.6/site-
> packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
> return super().__call__(environ, start_response)
> File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py",
> line 146, in __call__
> response = self.get_response(request)
> File "/usr/lib/python3.6/site-
> packages/django/contrib/staticfiles/handlers.py", line 62, in
> get_response
> return super().get_response(request)
> File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py",
> line 81, in get_response
> response = self._middleware_chain(request)
> TypeError: 'NoneType' object is not callable
> After page open
> .
> ----------------------------------------------------------------------
> Ran 1 test in 6.659s
>
> OK
> Destroying test database for alias 'default'...
>
> }}}
>
> This is my part of my settings:
>
> {{{
> STATIC_URL = '/static/'
> STATIC_ROOT = "/var/www/html/casino/static/"
> }}}
>
> It seems that url path cannot have the same name, because if I change
> STATIC_URL or STATIC_ROOT then everything works fine.
New description:
I created ''functional_tests'' directory with empty ''__init__.py'' and
''test_all.py'' containing following code:
{{{
from django.test import LiveServerTestCase
from selenium import webdriver
class DemoTest(LiveServerTestCase):
def test_can_get_empty_list_of_server_seeds(self):
self.browser = webdriver.Firefox()
print('Before page open')
self.browser.get(self.live_server_url + '/')
print('After page open')
self.assertEqual(1, 1)
self.browser.quit()
}}}
Running it with 'python manage.py test functional_tests/' result with
success:
{{{
...
Before page open
After page open
.
----------------------------------------------------------------------
Ran 1 test in 7.048s
OK
...
}}}
But if I change LiveServerTestCase to StaticLiveServerTestCase then I am
getting strange error:
{{{
$ python manage.py test functional_tests/
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
Before page open
Traceback (most recent call last):
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python3.6/site-
packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return super().__call__(environ, start_response)
File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py",
line 146, in __call__
response = self.get_response(request)
File "/usr/lib/python3.6/site-
packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
return super().get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py",
line 81, in get_response
response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python3.6/site-
packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return super().__call__(environ, start_response)
File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py",
line 146, in __call__
response = self.get_response(request)
File "/usr/lib/python3.6/site-
packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
return super().get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py",
line 81, in get_response
response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable
After page open
.
----------------------------------------------------------------------
Ran 1 test in 6.659s
OK
Destroying test database for alias 'default'...
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29353#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.2d2fd48f583d5a7397f030f1ba815daa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.