diff options
author | Guido van Rossum <guido@python.org> | 1999-03-29 19:59:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-03-29 19:59:32 (GMT) |
commit | 89ae2b9f071cb78322fd1df1571027cd7159a698 (patch) | |
tree | 53363c5b4fd6a04b1f4bc75ccbcac44d717bd99d /Lib/test/test_cpickle.py | |
parent | 4958f9af971fddaeaa8d447fb3eb130a897b8ba9 (diff) | |
download | cpython-89ae2b9f071cb78322fd1df1571027cd7159a698.zip cpython-89ae2b9f071cb78322fd1df1571027cd7159a698.tar.gz cpython-89ae2b9f071cb78322fd1df1571027cd7159a698.tar.bz2 |
Test protection against picling to/from closed (real) file.
Diffstat (limited to 'Lib/test/test_cpickle.py')
-rw-r--r-- | Lib/test/test_cpickle.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_cpickle.py b/Lib/test/test_cpickle.py index bedb321..90326f7 100644 --- a/Lib/test/test_cpickle.py +++ b/Lib/test/test_cpickle.py @@ -72,4 +72,24 @@ def dotest(): if x2 == x: print "ok" else: print "bad" + # Test protection against closed files + import tempfile, os + fn = tempfile.mktemp() + f = open(fn, "w") + f.close() + try: + cPickle.dump(123, f) + except IOError: + pass + else: + print "dump to closed file should raise IOError" + f = open(fn, "r") + f.close() + try: + cPickle.load(f) + except IOError: + pass + else: + print "load from closed file should raise IOError" + dotest() |