MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / output_hidden

Function output_hidden

archivebox/cli/tests.py:73–99  ·  view source on GitHub ↗
(show_failing=True)

Source from the content-addressed store, hash-verified

71
72@contextmanager
73def 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
102class TestInit(unittest.TestCase):

Callers 12

test_basic_initMethod · 0.85
test_conflicting_initMethod · 0.85
test_no_dirty_stateMethod · 0.85
setUpMethod · 0.85
test_add_arg_urlMethod · 0.85
test_add_arg_fileMethod · 0.85
test_add_stdin_urlMethod · 0.85
setUpMethod · 0.85
test_remove_exactMethod · 0.85
test_remove_regexMethod · 0.85
test_remove_domainMethod · 0.85
test_remove_noneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected