summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tempfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-04-28 16:17:26 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-04-28 16:17:26 (GMT)
commitd1a1def7bf221b04dcf3fc3a67aa19aa2f622f83 (patch)
tree0d13f2482de3cad5c65d9507d1bb4a27234578a6 /Lib/test/test_tempfile.py
parent80a3da4d4aad0b51893e1e2f696b6252eca80e07 (diff)
downloadcpython-d1a1def7bf221b04dcf3fc3a67aa19aa2f622f83.zip
cpython-d1a1def7bf221b04dcf3fc3a67aa19aa2f622f83.tar.gz
cpython-d1a1def7bf221b04dcf3fc3a67aa19aa2f622f83.tar.bz2
bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. (#1341)
* bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. They now work when delete replaced attribute or item inside the with statement. The old value of the attribute or item (or None if it doesn't exist) now will be assigned to the target of the "as" clause, if there is one. * Update docstrings.
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r--Lib/test/test_tempfile.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 51df1ec..d0cf04b 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -273,13 +273,12 @@ class TestGetDefaultTempdir(BaseTestCase):
tempfile._get_default_tempdir()
self.assertEqual(os.listdir(our_temp_directory), [])
- open = io.open
def bad_writer(*args, **kwargs):
- fp = open(*args, **kwargs)
+ fp = orig_open(*args, **kwargs)
fp.write = raise_OSError
return fp
- with support.swap_attr(io, "open", bad_writer):
+ with support.swap_attr(io, "open", bad_writer) as orig_open:
# test again with failing write()
with self.assertRaises(FileNotFoundError):
tempfile._get_default_tempdir()