Decorator to protect sys.dont_write_bytecode from mutation and to skip tests that require it to be set to False.
(fxn)
| 288 | |
| 289 | |
| 290 | def 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 | |
| 310 | def ensure_bytecode_path(bytecode_path): |
nothing calls this directly
no test coverage detected
searching dependent graphs…