classification
Title: new test for test_iter.py
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.2, Python 3.1, Python 2.7, Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Steve Howell, ezio.melotti, rhettinger
Priority: normal Keywords: patch

Created on 2010-01-26 08:12 by Steve Howell, last changed 2010-03-24 06:49 by Steve Howell.

Files
File name Uploaded Description Edit
extend_test.diff Steve Howell, 2010-01-29 17:57 review
Messages (5)
msg98320 - (view) Author: showell (Steve Howell) Date: 2010-01-26 08:12
I would like to submit the following test to be part of the test_iter.py test suite:

    def test_extends(self):
        # This test would break on an incomplete patch to listobject.c
        def gen():
            for i in range(500):
                yield i
        lst = [0] * 500
        for i in range(240):
            lst.pop(0)
        lst.extend(gen())

The history behind it is that I made a patch to listobject.c that obviously broke listextend(), but the tests did not catch it.  This was my failing test to improve my patch.  Regardless of what happens to the patch, I think it's a good idea to hammer on listextend() when it accepts an iterator, as it's a fairly tricky problem to extend a list when you do not know in advance how long it will be until the iterator gets exhausted.
msg98339 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-01-26 15:01
From the comment ("This test would break on an incomplete patch to listobject.c") is not clear what exactly the test is supposed to check.
Probably the test should include some assert* or more comments if it is supposed to work but it might raise an error if there's something wrong.
Finally it would be better if you can provide a patch against trunk and attach it to the issue.
msg98519 - (view) Author: showell (Steve Howell) Date: 2010-01-29 17:57
Per Ezio's suggestions, I added clearer comments and an assert, and now the attached diff applies to trunk.
msg101591 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-03-23 18:41
Can you produce a more tightly focused test, the minimum code that would have segfaulted your change?
msg101623 - (view) Author: showell (Steve Howell) Date: 2010-03-24 06:49
My proposed test is final.  Please either accept or reject it as is.  I assume it runs pretty quickly, so I am not sure what the cost fear is.  The benefit of accepting the test is that it would potentially catch bugs on changes to the implementation of list.
History
Date User Action Args
2010-03-24 06:49:35Steve Howellsetmessages: + msg101623
2010-03-23 18:41:45rhettingersetmessages: + msg101591
2010-01-29 18:48:27pitrousetnosy: + rhettinger
2010-01-29 17:57:23Steve Howellsetfiles: + extend_test.diff
keywords: + patch
messages: + msg98519
2010-01-26 15:01:16ezio.melottisetpriority: normal
versions: + Python 2.6, Python 3.1, Python 2.7
nosy: + ezio.melotti

messages: + msg98339

stage: patch review
2010-01-26 08:12:04Steve Howellcreate