MCPcopy Index your code
hub / github.com/python/cpython / writes_bytecode_files

Function writes_bytecode_files

Lib/test/test_importlib/util.py:290–307  ·  view source on GitHub ↗

Decorator to protect sys.dont_write_bytecode from mutation and to skip tests that require it to be set to False.

(fxn)

Source from the content-addressed store, hash-verified

288
289
290def writes_bytecode_files(fxn):
291 """Decorator to protect sys.dont_write_bytecode from mutation and to skip
292 tests that require it to be set to False."""
293 if sys.dont_write_bytecode:
294 return unittest.skip("relies on writing bytecode")(fxn)
295 if sys.implementation.cache_tag is None:
296 return unittest.skip("requires sys.implementation.cache_tag to not be None")(fxn)
297
298 @functools.wraps(fxn)
299 def wrapper(*args, **kwargs):
300 original = sys.dont_write_bytecode
301 sys.dont_write_bytecode = False
302 try:
303 to_return = fxn(*args, **kwargs)
304 finally:
305 sys.dont_write_bytecode = original
306 return to_return
307 return wrapper
308
309
310def ensure_bytecode_path(bytecode_path):

Callers

nothing calls this directly

Calls 1

skipMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…