Issue #11049: adding some tests to test.support
Based on original patch by Giampaolo Rodola with contributions from R. David Murray
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 @@
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 @@
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 @@
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'
#=======================================================================