summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2011-07-23 05:48:53 (GMT)
committerEli Bendersky <eliben@gmail.com>2011-07-23 05:48:53 (GMT)
commit6c51999221ef92002769228bd2bc80066c60f357 (patch)
tree54ea6dcd515dd34681ce08b37fbb8d9aebb4d635 /Lib/test/support.py
parent54ef40b00052166548e3f050446ca0b134424f93 (diff)
downloadcpython-6c51999221ef92002769228bd2bc80066c60f357.zip
cpython-6c51999221ef92002769228bd2bc80066c60f357.tar.gz
cpython-6c51999221ef92002769228bd2bc80066c60f357.tar.bz2
Issue #11049: adding some tests to test.support
Based on original patch by Giampaolo Rodola with contributions from R. David Murray
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 89ace45..278348e 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -170,7 +170,7 @@ def get_attribute(obj, name):
attribute = getattr(obj, name)
except AttributeError:
raise unittest.SkipTest("module %s has no attribute %s" % (
- obj.__name__, name))
+ repr(obj), name))
else:
return attribute
@@ -577,14 +577,15 @@ def temp_cwd(name='tempcwd', quiet=False, path=None):
rmtree(name)
-@contextlib.contextmanager
-def temp_umask(umask):
- """Context manager that temporarily sets the process umask."""
- oldmask = os.umask(umask)
- try:
- yield
- finally:
- os.umask(oldmask)
+if hasattr(os, "umask"):
+ @contextlib.contextmanager
+ def temp_umask(umask):
+ """Context manager that temporarily sets the process umask."""
+ oldmask = os.umask(umask)
+ try:
+ yield
+ finally:
+ os.umask(oldmask)
def findfile(file, here=__file__, subdir=None):
@@ -1029,7 +1030,7 @@ def python_is_optimized():
for opt in cflags.split():
if opt.startswith('-O'):
final_opt = opt
- return final_opt and final_opt != '-O0'
+ return final_opt != '' and final_opt != '-O0'
#=======================================================================