summaryrefslogtreecommitdiff
path: root/Lib/test/test_iter.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix test_iter after the dict views conversion.Brett Cannon2007-02-221-7/+7
|
* - PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;Guido van Rossum2007-02-111-14/+14
| | | | | | | | | | and .keys(), .items(), .values() return dict views. The dict views aren't fully functional yet; in particular, they can't be compared to sets yet. but they are useful as "iterator wells". There are still 27 failing unit tests; I expect that many of these have fairly trivial fixes, but there are so many, I could use help.
* - patch #1600346 submitted by Tomer FilibaJack Diederich2006-11-281-3/+3
| | | | | | - Renamed nb_nonzero slots to nb_bool - Renamed __nonzero__ methods to __bool__ - update core, lib, docs, and tests to match
* Make built-in zip() equal to itertools.izip().Guido van Rossum2006-08-241-13/+16
| | | | | | | I mea, *really* equal -- for now, the implementation just imports itertools. :-) The only other changes necessary were various unit tests that were assuming zip() returns a real list. No "real" code made this assumption.
* Anna Ravenscroft identified many occurrences of "file" used to open a fileAlex Martelli2006-08-241-2/+2
| | | | | | in the stdlib and changed each of them to use "open" instead. At this time there are no other known occurrences that can be safely changed (in Lib and all subdirectories thereof).
* Kill reduce(). A coproduction of John Reese, Jacques Frechet, and Alex M.Guido van Rossum2006-08-221-13/+0
|
* As discussed on python-dev, changed builtin.zip() to handle zero argumentsRaymond Hettinger2003-08-021-1/+4
| | | | by returning an empty list instead of raising a TypeError.
* Don't rebind True and False.Tim Peters2002-12-231-5/+5
|
* Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py.Guido van Rossum2002-08-061-2/+2
|
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+1
| | | | | | | | | | | imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
* Bunch of tests to make sure that StopIteration is a sink state.Guido van Rossum2002-07-161-0/+76
|
* builtin_zip(): Take a good guess at how big the result list will be,Tim Peters2002-04-291-0/+28
| | | | | | | and allocate it in one gulp. This isn't a bugfix, it's just a minor optimization that may or may not pay off.
* unpack_iterable(): Add a missing DECREF in an error case. Reported byGuido van Rossum2001-12-031-0/+23
| | | | | Armin Rigo (SF bug #488477). Added a testcase to test_unpack_iter() in test_iter.py.
* Whitespace normalization.Tim Peters2001-10-041-4/+4
|
* Generalize file.writelines() to allow iterable objects.Tim Peters2001-09-231-0/+53
|
* Change the PyUnit-based tests to use the test_main() approach. ThisFred Drake2001-09-201-1/+7
| | | | | allows using the tests with unittest.py as a script. The tests will still run when run as a script themselves.
* Generalize operator.indexOf (PySequence_Index) to work with anyTim Peters2001-09-081-0/+41
| | | | | | | | | | iterable object. I'm not sure how that got overlooked before! Got rid of the internal _PySequence_IterContains, introduced a new internal _PySequence_IterSearch, and rewrote all the iteration-based "count of", "index of", and "is the object in it or not?" routines to just call the new function. I suppose it's slower this way, but the code duplication was getting depressing.
* Patch #445762: Support --disable-unicodeMartin v. Löwis2001-08-171-5/+11
| | | | | | | | - Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
* Teach the UNPACK_SEQUENCE opcode how to tease an iterable object intoTim Peters2001-06-211-0/+53
| | | | | giving up the goods. NEEDS DOC CHANGES
* Generalize zip() to work with iterators.Tim Peters2001-05-061-0/+46
| | | | | | | | NEEDS DOC CHANGES. More AttributeErrors transmuted into TypeErrors, in test_b2.py, and, again, this strikes me as a good thing. This checkin completes the iterator generalization work that obviously needed to be done. Can anyone think of others that should be changed?
* Get rid of silly 5am "del" stmts.Tim Peters2001-05-051-2/+0
|
* Reimplement PySequence_Contains() and instance_contains(), so they workTim Peters2001-05-051-18/+6
| | | | | | | | | safely together and don't duplicate logic (the common logic was factored out into new private API function _PySequence_IterContains()). Visible change: some_complex_number in some_instance no longer blows up if some_instance has __getitem__ but neither __contains__ nor __iter__. test_iter changed to ensure that remains true.
* Generalize PySequence_Count() (operator.countOf) to work with iterators.Tim Peters2001-05-051-0/+35
|
* Make 'x in y' and 'x not in y' (PySequence_Contains) play nice w/ iterators.Tim Peters2001-05-051-0/+55
| | | | | | | | | | | | | NEEDS DOC CHANGES A few more AttributeErrors turned into TypeErrors, but in test_contains this time. The full story for instance objects is pretty much unexplainable, because instance_contains() tries its own flavor of iteration-based containment testing first, and PySequence_Contains doesn't get a chance at it unless instance_contains() blows up. A consequence is that some_complex_number in some_instance dies with a TypeError unless some_instance.__class__ defines __iter__ but does not define __getitem__.
* Make unicode.join() work nice with iterators. This also required a changeTim Peters2001-05-051-0/+41
| | | | | | | | to string.join(), so that when the latter figures out in midstream that it really needs unicode.join() instead, unicode.join() can actually get all the sequence elements (i.e., there's no guarantee that the sequence passed to string.join() can be iterated over *again* by unicode.join(), so string.join() must not pass on the original sequence object anymore).
* Generalize tuple() to work nicely with iterators.Tim Peters2001-05-051-0/+33
| | | | | | | | | | | | | | | | | | | | | NEEDS DOC CHANGES. This one surprised me! While I expected tuple() to be a no-brainer, turns out it's actually dripping with consequences: 1. It will *allow* the popular PySequence_Fast() to work with any iterable object (code for that not yet checked in, but should be trivial). 2. It caused two std tests to fail. This because some places used PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test whether something *is* a sequence. But tuple() code only looked for the existence of sq->item to determine that, and e.g. an instance passed that test whether or not it supported the other operations tuple() needed (e.g., __len__). So some things the tests *expected* to fail with an AttributeError now fail with a TypeError instead. This looks like an improvement to me; e.g., test_coercion used to produce 559 TypeErrors and 2 AttributeErrors, and now they're all TypeErrors. The error details are more informative too, because the places calling this were *looking* for TypeErrors in order to replace the generic tuple() "not a sequence" msg with their own more specific text, and AttributeErrors snuck by that.
* Generalize reduce() to work with iterators.Tim Peters2001-05-041-0/+13
| | | | NEEDS DOC CHANGES.
* Purge redundant cut&paste line.Tim Peters2001-05-031-2/+1
|
* Generalize map() to work with iterators.Tim Peters2001-05-031-0/+35
| | | | | | | | | | | NEEDS DOC CHANGES. Possibly contentious: The first time s.next() yields StopIteration (for a given map argument s) is the last time map() *tries* s.next(). That is, if other sequence args are longer, s will never again contribute anything but None values to the result, even if trying s.next() again could yield another result. This is the same behavior map() used to have wrt IndexError, so it's the only way to be wholly backward-compatible. I'm not a fan of letting StopIteration mean "try again later" anyway.
* Remove redundant copy+paste code.Tim Peters2001-05-031-3/+0
|
* Generalize max(seq) and min(seq) to work with iterators.Tim Peters2001-05-031-0/+35
| | | | NEEDS DOC CHANGES.
* Generalize filter(f, seq) to work with iterators. This also generalizesTim Peters2001-05-021-0/+44
| | | | | filter() to no longer insist that len(seq) be defined. NEEDS DOC CHANGES.
* Generalize list(seq) to work with iterators. This also generalizes list()Tim Peters2001-05-011-0/+32
| | | | | | | | | | | | | to no longer insist that len(seq) be defined. NEEDS DOC CHANGES. This is meant to be a model for how other functions of this ilk (max, filter, etc) can be generalized similarly. Feel encouraged to grab your favorite and convert it! Note some cute consequences: list(file) == file.readlines() == list(file.xreadlines()) list(dict) == dict.keys() list(dict.iteritems()) = dict.items() list(xrange(i, j, k)) == range(i, j, k)
* Add test suite for iterators.Guido van Rossum2001-04-211-0/+246