(show_failing=True)
| 71 | |
| 72 | @contextmanager |
| 73 | def output_hidden(show_failing=True): |
| 74 | if not HIDE_CLI_OUTPUT: |
| 75 | yield |
| 76 | return |
| 77 | |
| 78 | sys.stdout = open('stdout.txt', 'w+', encoding='utf-8') |
| 79 | sys.stderr = open('stderr.txt', 'w+', encoding='utf-8') |
| 80 | try: |
| 81 | yield |
| 82 | sys.stdout.close() |
| 83 | sys.stderr.close() |
| 84 | sys.stdout = stdout |
| 85 | sys.stderr = stderr |
| 86 | except Exception: |
| 87 | sys.stdout.close() |
| 88 | sys.stderr.close() |
| 89 | sys.stdout = stdout |
| 90 | sys.stderr = stderr |
| 91 | if show_failing: |
| 92 | with open('stdout.txt', 'r', encoding='utf-8') as f: |
| 93 | print(f.read()) |
| 94 | with open('stderr.txt', 'r', encoding='utf-8') as f: |
| 95 | print(f.read()) |
| 96 | raise |
| 97 | finally: |
| 98 | os.remove('stdout.txt') |
| 99 | os.remove('stderr.txt') |
| 100 | |
| 101 | |
| 102 | class TestInit(unittest.TestCase): |
no outgoing calls
no test coverage detected