summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
Commit message (Collapse)AuthorAgeFilesLines
* Add doctest for examples in libweakref.tex to test_weakref.Georg Brandl2005-07-021-0/+86
|
* SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior.Raymond Hettinger2005-03-271-0/+6
|
* SF bug #978308, Spurious errors taking bool of dead proNeal Norwitz2004-07-081-0/+1
| | | | | | Need to return -1 on error. Needs backport.
* Make weak references subclassable:Fred Drake2004-07-021-0/+66
| | | | | | | | | | | | | | | | | | | | | | - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019.
* Rename class attribute containing the class to be tested, so the name is theWalter Dörwald2004-06-021-2/+2
| | | | same as for the string and sequence tests.
* Port the dictionary tests from test_types.py to unittest. Collect as muchWalter Dörwald2004-05-311-3/+3
| | | | | | mapping tests as possible in mapping_test.py and reuse the tests in test_dict.py, test_userdict.py, test_weakref.py, test_os.py and test_shelve.py. From SF patch #736962.
* further testing indicates that the simplified version of the testFred Drake2004-02-131-4/+6
| | | | | | | | | | (re-using an existing test object class) no longer triggered the original segfault when the fix was backed out; restoring the local test object class to make the test effective the assignment of the ref created at the end does not affect the test, since the segfault happended before weakref.ref() returned; removing the assignment
* use existing test object instead of defining a new classFred Drake2004-02-121-5/+3
|
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-1/+1
| | | | From SF patch #852334.
* Allocating a new weakref object can cause existing weakref objects forFred Drake2004-02-041-0/+32
| | | | | | | | | the same object to be collected by the cyclic GC support if they are only referenced by a cycle. If the weakref being collected was one of the weakrefs without callbacks, some local variables for the constructor became invalid and have to be re-computed. The test caused a segfault under a debug build without the fix applied.
* - add tests that exercise fixes for the PyWeakref_NewRef() andFred Drake2004-02-031-0/+41
| | | | | PyWeakref_NewProxy() constructors from the C API - elaborate the getweakrefcount() and getweakrefs() tests slightly
* Add tests to test_weakref.py to bring code coverage in _weakref.c up to 100%.Walter Dörwald2003-12-111-0/+8
| | | | | | | | Port test_md5.py to PyUnit. (Written by Neal Norwitz; from SF patch 736962) (Backport candidate)
* SF bug 839548: Bug in type's GC handling causes segfaults.Tim Peters2003-11-201-0/+205
| | | | | | | | Also SF patch 843455. This is a critical bugfix. I'll backport to 2.3 maint, but not beyond that. The bugs this fixes have been there since weakrefs were introduced.
* * Migrate set() and frozenset() from the sandbox.Raymond Hettinger2003-11-161-2/+1
| | | | | | | | * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming.
* subtype_dealloc(): A more complete fix for critical bug 840829 +Tim Peters2003-11-131-0/+19
| | | | | | expanded the test case with a piece that needs the more-complete fix. I'll backport this to 2.3 maint.
* SF bug 840829: weakref callbacks and gc corrupt memory.Tim Peters2003-11-121-0/+20
| | | | | | | | | | | | | | | | | subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later.
* stylistic nits:Fred Drake2003-07-141-6/+8
| | | | | | - wrap some long lines - shorten others - fix indentation
* Fix SF 762891: "del p[key]" on proxy object raises SystemError()Raymond Hettinger2003-06-301-0/+11
|
* Fleshed out WeakKeyDictionary.__delitem__ NEWS to cover issues raised onTim Peters2003-05-251-2/+10
| | | | | | | | | Python-Dev. Fixed typos in test comments. Added some trivial new test guts to show the parallelism (now) among __delitem__, __setitem__ and __getitem__ wrt error conditions. Still a bugfix candidate for 2.2.3 final, but waiting for Fred to get a chance to chime in.
* SF 742860: WeakKeyDictionary __delitem__ uses iterkeysTim Peters2003-05-251-0/+51
| | | | | | | | | | | | | | | | | Someone review this, please! Final releases are getting close, Fred (the weakref guy) won't be around until Tuesday, and the pre-patch code can indeed raise spurious RuntimeErrors in the presence of threads or mutating comparison functions. See the bug report for my confusions: I can't see any reason for why __delitem__ iterated over the keys. The new one-liner implementation is much faster, can't raise RuntimeError, and should be better-behaved in all respects wrt threads. New tests test_weak_keyed_bad_delitem and test_weak_keyed_cascading_deletes fail before this patch. Bugfix candidate for 2.2.3 too, if someone else agrees with this patch.
* Used sets.Set() to compare unordered sequences.Raymond Hettinger2003-05-021-3/+2
| | | | Improves clarity and brevity.
* Combine the functionality of test_support.run_unittest()Walter Dörwald2003-05-011-6/+6
| | | | | | | | | | 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.
* SF patch #667730: More DictMixinRaymond Hettinger2003-03-091-0/+17
| | | | | | | | * Adds missing pop() methods to weakref.py * Expands test suite to broaden coverage of objects with a mapping interface. Contributed by Sebastien Keim.
* Standardize behavior: no docstrings in test functions. Also useGuido van Rossum2002-08-221-6/+4
| | | | unittest.makeSuite() rather than loader.loadTestsFromTestCase().
* 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. :)
* SF patch 564549 (Erik Andersén).Guido van Rossum2002-06-101-0/+11
| | | | | | | The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate.
* Improve coverage of Objects/weakrefobject.c.Fred Drake2002-04-111-0/+16
|
* Add some additional tests that check more proxy behaviors.Fred Drake2001-12-191-0/+18
|
* Regression test for SF bug #478534 -- exceptions could "leak" into a weakrefFred Drake2001-12-101-0/+25
| | | | callback.
* Add a regression test for SF bug #478536: If a value cannot be weaklyFred Drake2001-11-061-1/+5
| | | | | referenced, WeakKeyDictionary.has_key() should return 0 instead of raising TypeError.
* Add a test for calling a weakref proxy with a dictionary of keyword args.Fred Drake2001-10-181-0/+3
|
* Make sure we do not core dump when using proxies with the binary slotFred Drake2001-10-181-0/+8
| | | | handlers. This was fixed in Objects/weakrefobject.c 1.2.
* Change the PyUnit-based tests to use the test_main() approach. ThisFred Drake2001-09-201-3/+11
| | | | | allows using the tests with unittest.py as a script. The tests will still run when run as a script themselves.
* Added tests for key deletion for both Weak*Dictionary flavors.Fred Drake2001-09-061-0/+22
| | | | This covers regression on SF bug #458860.
* Make sure that WeakValueDictionary[] raises KeyError instead of TypeErrorFred Drake2001-08-031-0/+5
| | | | for keys that are not in the dictionary.
* Extend the weakref test suite to cover the complete mapping interface forFred Drake2001-05-101-4/+61
| | | | | | both weakref.Weak*Dictionary classes. This closes SF bug #416480.
* Added tests for Weak*Dictionary iterator support.Fred Drake2001-05-021-10/+54
| | | | Refactored some object initialization to be more reusable.
* Add a test case for Weak*Dictionary.update() that would have caught aFred Drake2001-04-161-0/+25
| | | | recently reported bug; also exposed some other bugs in the implementation.
* Added regression test for SF bug #415660 (failure to invalidate allFred Drake2001-04-131-5/+24
| | | | | | references to an object before calling registered callbacks). Change last uses of verify() to self.assert_().
* Use the WeakKeyDictionary and WeakValueDictionary classes directlyFred Drake2001-04-101-2/+2
| | | | instead of using the mapping() function.
* Convert the weakref test suite to PyUNIT, and add tests that exercise weakFred Drake2001-03-231-236/+252
| | | | references on function objects and both bound and unbound methods.
* Add tests for the .copy() methods of both weak dictionary classes.Fred Drake2001-03-011-1/+15
|
* Patch #403985: Add support for weak-keyed dictionariesMartin v. Löwis2001-02-271-0/+18
|
* PEP 205, Weak References -- initial checkin.Fred Drake2001-02-011-0/+218