Opened 10 years ago
Closed 10 years ago
#23464 closed Bug (invalid)
Random exception when running unit tests.
Reported by: | ErikW | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After upgrading to Django 1.7, my test suite now randomly throws this exception 80% of the time. Not sure why this would happen intermittently like this.
====================================================================== ERROR: test_get_list_json (api.tests.test_user_drf.UserResourceTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/erik/Dropbox/home/git/proj/api/tests/test_user_drf.py", line 48, in test_get_list_json resp = self.client.get('/api/drf/user/', content_type="application/json", HTTP_AUTHORIZATION=self.get_credentials()) File "/Users/erik/.virtualenvs/proj/src/django-tastypie/tastypie/test.py", line 68, in get return self.client.get(uri, **kwargs) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/test/client.py", line 467, in get **extra) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/test/client.py", line 285, in get return self.generic('GET', path, secure=secure, **r) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/test/client.py", line 355, in generic return self.request(**r) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/test/client.py", line 419, in request response = self.handler(environ) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/test/client.py", line 110, in __call__ response = self.get_response(request) File "/Users/erik/.virtualenvs/proj/lib/python2.7/site-packages/django/core/handlers/base.py", line 210, in get_response response._closable_objects.append(request) AttributeError: 'Response' object has no attribute '_closable_objects' ---------------------------------------------------------------------- Ran 1 test in 0.322s FAILED (errors=1) Destroying test database for alias 'default'...
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
This is definitely related to caching. When I flush my cache, the tests run fine, but if I immediately run it a seconds time before the cached objects have expired, I get the traceback.
It looks like _closed_objects
isn't serialized when the objects are pickled for caching.
This doesn't seem to be limited to a particular backend -- I've tested with FileBasedCache, Memcached,and Redis.
comment:3 by , 10 years ago
kezabelle: didn't see your response before I posted about caching. I'll take a look at those other issues...
comment:4 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The root cause if this issue is DRF excluding _closable_objects
from cached (pickled) response objects. Tom or Xavier could explain why pickling _closable_objects
may be problematic, and then open a separate ticket about that problem.
Response
is, AFAIK, a DRF thing, and there's an open ticket on the DRF issue tracker here which seems a likely candidate. Possibly the problem exists in either DRF or tastypie? (Both are listed in your stacktrace)