diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-05-11 01:47:11 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-05-11 01:47:11 (GMT) |
commit | 1262e7c7468b6a92a680161c322a0234b526e3db (patch) | |
tree | 810d23e94fd2bf85148588e3ec22caf1b0cf79dd /Lib/importlib/test/source/util.py | |
parent | cc3b8d6883f52391c59f59e82bfa1840e2847d90 (diff) | |
download | cpython-1262e7c7468b6a92a680161c322a0234b526e3db.zip cpython-1262e7c7468b6a92a680161c322a0234b526e3db.tar.gz cpython-1262e7c7468b6a92a680161c322a0234b526e3db.tar.bz2 |
Tests for case-senstivity were not being skipped for darwin when installed on a
case-sensitive filesystems -- which is not the default case. Along the way also
fixed the skipping of tests when sys.dont_write_bytecode is true.
Closes issue #5442 again.
Diffstat (limited to 'Lib/importlib/test/source/util.py')
-rw-r--r-- | Lib/importlib/test/source/util.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Lib/importlib/test/source/util.py b/Lib/importlib/test/source/util.py index 280edb4..ca04edf 100644 --- a/Lib/importlib/test/source/util.py +++ b/Lib/importlib/test/source/util.py @@ -9,32 +9,23 @@ import tempfile from test import support -def writes_bytecode(fxn): - """Decorator to protect sys.dont_write_bytecode from mutation.""" +def writes_bytecode_files(fxn): + """Decorator to protect sys.dont_write_bytecode from mutation and to skip + tests that require it to be set to False.""" + if sys.dont_write_bytecode: + return lambda *args, **kwargs: None @functools.wraps(fxn) def wrapper(*args, **kwargs): original = sys.dont_write_bytecode sys.dont_write_bytecode = False - to_return = fxn(*args, **kwargs) - sys.dont_write_bytecode = original + try: + to_return = fxn(*args, **kwargs) + finally: + sys.dont_write_bytecode = original return to_return return wrapper -def writes_bytecode_files(fxn): - """Decorator that returns the function if writing bytecode is enabled, else - a stub function that accepts anything and simply returns None.""" - if sys.dont_write_bytecode: - return lambda *args, **kwargs: None - else: - @functools.wraps(fxn) - def wrapper(*args, **kwargs): - to_return = fxn(*args, **kwargs) - sys.dont_write_bytecode = False - return to_return - return wrapper - - def bytecode_path(source_path): for suffix, _, type_ in imp.get_suffixes(): if type_ == imp.PY_COMPILED: |