#10753 closed (fixed)
Test client fails after 10398
Reported by: | Ville Säävuori | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | testing signals | |
Cc: | ratsam@…, minmax@…, sopelkin@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After changeset r10398 my tests started failing for an app that uses signals. (post_save signal in this case -- nothing special in there)
Traceback from the test client:
Traceback (most recent call last): File "/home/syneusfi/new_intra/pylib/heimlich/tests.py", line 142, in test_ticket_creation response = self.client.post('/partiovaruste/bugilista/uusi/', postdata) File "/home/syneusfi/django/django/test/client.py", line 306, in post response = self.request(**r) File "/home/syneusfi/django/django/test/client.py", line 224, in request response = self.handler(environ) File "/home/syneusfi/django/django/test/client.py", line 75, in __call__ signals.request_finished.disconnect(close_connection) File "/home/syneusfi/django/django/dispatch/dispatcher.py", line 124, in disconnect (r_key, _) = self.receivers[index] IndexError: list index out of range
The tests in question pass for revision r10397. I tested that they also pass when reverting only django/django/dispatch/dispatcher.py
to the previous revision, so I'm quite confident that r10398 broke something here.
Attachments (2)
Change History (14)
follow-up: 6 comment:1 by , 16 years ago
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
see http://code.djangoproject.com/changeset/10398 dispatcher.py
example:
In [1]: l = [1,2,3]
In [2]: for i in xrange(len(l)):
...: del l[i]
IndexError Traceback (most recent call last)
IndexError: list assignment index out of range
by , 16 years ago
comment:5 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
- This isn't fixed until the patch is applied to trunk.
- The patch doesn't contain a test case.
- The test case you have provided in the comments is pure python - it doesn't contain any Django code. The example breaks for a very good reason - after deleting two items from the list, there isn't an l[2] to delete. This is purely normal python behaviour.
comment:6 by , 16 years ago
Replying to russellm:
Any chance you could give us an example of a test that is actually failing?
I wrote a small test project + testapp to demonstrate this but I couldn't reproduce the bug in there. I'll try to strip out the problematic app+test from the original project next.
Weird thing is, this was the only test that broke in dozens of projects with lots of tests. But I'm still quite sure it's a bug in Django.
comment:7 by , 16 years ago
This issue occurs when there are more than one listener and the last one is disconnected.
test case with django:
s = Signal()
r1 = lambda kw: None
r2 = lambda kw: None
s.connect(r1)
s.connect(r2)
s.disconnect(r1)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/minmax/projects/lib/django/dispatch/dispatcher.py", line 124, in disconnect
(r_key, _) = self.receivers[index]
IndexError: list index out of range
comment:8 by , 16 years ago
sorry
>>> s = Signal() >>> r1 = lambda **kw: None >>> r2 = lambda **kw: None >>> s.connect(r1) >>> s.connect(r2) >>> s.disconnect(r1) Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/minmax/projects/lib/django/dispatch/dispatcher.py", line 124, in disconnect (r_key, _) = self.receivers[index] IndexError: list index out of range
by , 16 years ago
comment:9 by , 16 years ago
Component: | Uncategorized → Core framework |
---|---|
Owner: | changed from | to
Status: | reopened → new |
Triage Stage: | Unreviewed → Accepted |
I'm getting this error as well, after [10398]. Thanks for the patch -- I'm going to take a look.
comment:10 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Any chance you could give us an example of a test that is actually failing? It's great to know that you have a test that is failing, but unless you can give us the actual test, it is a lot more difficult to diagnose what is going on here.