summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sets.py
Commit message (Collapse)AuthorAgeFilesLines
* Restructure comparison dramatically. There is no longer a defaultGuido van Rossum2006-08-241-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *ordering* between objects; there is only a default equality test (defined by an object being equal to itself only). Read the comment in object.c. The current implementation never uses a three-way comparison to compute a rich comparison, but it does use a rich comparison to compute a three-way comparison. I'm not quite done ripping out all the calls to PyObject_Compare/Cmp, or replacing tp_compare implementations with tp_richcompare implementations; but much of that has happened (to make most unit tests pass). The following tests still fail, because I need help deciding or understanding: test_codeop -- depends on comparing code objects test_datetime -- need Tim Peters' opinion test_marshal -- depends on comparing code objects test_mutants -- need help understanding it The problem with test_codeop and test_marshal is this: these tests compare two different code objects and expect them to be equal. Is that still a feature we'd like to support? I've temporarily removed the comparison and hash code from code objects, so they use the default (equality by pointer only) comparison. For the other two tests, run them to see for yourself. (There may be more failing test with "-u all".) A general problem with getting lots of these tests to pass is the reality that for object types that have a natural total ordering, implementing __cmp__ is much more convenient than implementing __eq__, __ne__, __lt__, and so on. Should we go back to allowing __cmp__ to provide a total ordering? Should we provide some other way to implement rich comparison with a single method override? Alex proposed a __key__() method; I've considered a __richcmp__() method. Or perhaps __cmp__() just shouldn't be killed off...
* Use relative import now that it is required. (Should this go into 2.5?)Neal Norwitz2006-03-241-1/+2
|
* Teach the sets module to correctly compute s-=s and s^=s as the empty set.Raymond Hettinger2005-08-131-0/+13
|
* Exercise DocTestSuite's search for __test__.Raymond Hettinger2004-08-071-2/+2
|
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-2/+2
| | | | From SF patch #852334.
* Add more identity tests.Raymond Hettinger2003-09-241-0/+11
|
* Improve and expand identity tests.Raymond Hettinger2003-09-211-11/+18
|
* SF patch #736962: Port tests to unittestRaymond Hettinger2003-08-301-0/+10
| | | | | | | | (Contributed by Walter Dörwald). * Convert three test modules to unittest format. * Expanded coverage in test_structseq.py. * Raymond added a new test in test_sets.py
* Improvements to set.py:Raymond Hettinger2003-08-171-11/+133
| | | | | | | | | | | | | | | | | | | * Relaxed the argument restrictions for non-operator methods. They now allow any iterable instead of requiring a set. This makes the module a little easier to use and paves the way for an efficient C implementation which can take better advantage of iterable arguments while screening out immutables. * Deprecated Set.update() because it now duplicates Set.union_update() * Adapted the tests and docs to include the above changes. * Added more test coverage including testing identities and checking to make sure non-restartable generators work as arguments. Will backport to Py2.3.1 so that the interface remains consistent across versions. The deprecation of update() will be changed to a FutureWarning.
* Keep doctests in sync with the docs.Raymond Hettinger2003-08-161-5/+5
|
* Combine the functionality of test_support.run_unittest()Walter Dörwald2003-05-011-32/+24
| | | | | | | | | | and test_support.run_classtests() into run_unittest() and use it wherever possible. Also don't use "from test.test_support import ...", but "from test import test_support" in a few spots. From SF patch #662807.
* TestOnlySetsInBinaryOps: Simplified the non-inplace tests by usingTim Peters2003-03-021-44/+16
| | | | | | assertRaises. Fixed a repeated subtle bug in the inplace tests by removing the possibilty that a self.fail() call could raise a TypeError that the test catches by mistake.
* Typo repairs in new code.Tim Peters2003-03-021-3/+7
|
* SF bug 693121: Set == non-Set is a TypeError.Tim Peters2003-03-021-12/+23
| | | | | | | | | Allow mixed-type __eq__ and __ne__ for Set objects. This is messier than I'd like because Set *also* implements __cmp__. I know of one glitch now: cmp(s, t) returns 0 now when s and t are both Sets and s == t, despite that Set.__cmp__ unconditionally raises TypeError (and by intent). The rub is that __eq__ gets tried first, and the x.__eq__(y) True result convinces Python that cmp(x, y) is 0 without even calling Set.__cmp__.
* The doctest was printing Sets, but that's unreliable because setTim Peters2003-03-011-6/+9
| | | | | elements get displayed in undefined dict order. Use a Set subclass instead (which arranges to sort the elements for display).
* * Add test for __cmp__()Raymond Hettinger2003-01-151-2/+40
| | | | * Add doctest for example in the library reference manual
* SF 643115: Set._update() had a special case for dictionaries which allowedRaymond Hettinger2002-11-251-0/+3
| | | | | non-true values to leak in. This threw-off equality testing which depends on the underlying dictionaries having both the same keys and values.
* remove debugging printJeremy Hylton2002-11-131-2/+0
|
* Add getstate and setstate implementation to concrete set classes.Jeremy Hylton2002-11-131-1/+9
|
* Whitespace normalization.Tim Peters2002-11-091-4/+4
|
* Closes SF bug #628246.Raymond Hettinger2002-11-081-0/+25
| | | | | | | | The _update method detected mutable elements by trapping TypeErrors. Unfortunately, this masked useful TypeErrors raised by the iterable itself. For cases where it is possible for an iterable to raise a TypeError, the iterable is pre-converted to a list outside the try/except so that any TypeErrors propagate through.
* Implemented <, <=, >, >= for sets, giving subset and proper-subsetTim Peters2002-08-251-7/+21
| | | | | | meanings. I did not add new, e.g., ispropersubset() methods; we're going nuts on those, and, e.g., there was no "friendly name" for == either.
* TestSubset(): Generalized the framework to support testing upcomingTim Peters2002-08-251-10/+23
| | | | <, <=, etc methods too.
* Rewrote all remaining assert stmts.Tim Peters2002-08-251-30/+30
|
* Simplified construction of the test suite.Tim Peters2002-08-251-21/+23
|
* Simplified code building sets of characters.Tim Peters2002-08-251-5/+5
|
* Ack! Virtually every test here relied on an assert stmt. assert stmtsTim Peters2002-08-251-60/+60
| | | | should never be used in tests. Repaired dozens, but more is needed.
* Simplified the setup for is-subset testing.Tim Peters2002-08-251-25/+20
|
* Removed < <= > >= from the API. Implemented as comparisons of theRaymond Hettinger2002-08-241-2/+2
| | | | | | | | underlying dictionaries, there were no reasonable use cases (lexicographic sorting of a list of sets is somewhat esoteric). Frees the operators for other uses (such as strict subset and superset comparisons). Updated documentation and test suite accordingly.
* At Tim Peter's suggestion, propagated GvR's binary operator changes toRaymond Hettinger2002-08-241-0/+32
| | | | | | | | | | | | the inplace operators. The strategy is to have the operator overloading code do the work and then to define equivalent method calls which rely on the operators. The changes facilitate proper application of TypeError and NonImplementedErrors. Added corresponding tests to the test suite to make sure both the operator and method call versions get exercised. Add missing tests for difference_update().
* Expanded tests for sets of sets.Raymond Hettinger2002-08-241-0/+4
|
* Add regression test for proper construction of sets of sets.Raymond Hettinger2002-08-211-0/+10
|
* Rename popitem() to pop(). (An idea from SF patch 597444.)Guido van Rossum2002-08-201-2/+2
|
* Set classes and their unit tests, from sandbox.Guido van Rossum2002-08-191-0/+568