Skip to content

Commit 8eee614

Browse files
pytest: refactor reckless check_stderr
1 parent 61fa5d9 commit 8eee614

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

tests/test_reckless.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ def search_stdout(self, regex):
111111
matching.append(line)
112112
return matching
113113

114+
def check_stderr(self):
115+
def output_okay(out):
116+
for warning in ['[notice]', 'WARNING:', 'npm WARN',
117+
'npm notice', 'DEPRECATION:', 'Creating virtualenv',
118+
'config file not found:', 'press [Y]']:
119+
if out.startswith(warning):
120+
return True
121+
return False
122+
for e in self.stderr:
123+
if len(e) < 1:
124+
continue
125+
# Don't err on verbosity from pip, npm
126+
if not output_okay(e):
127+
raise Exception(f'reckless stderr contains `{e}`')
128+
114129

115130
def reckless(cmds: list, dir: PosixPath = None,
116131
autoconfirm=True, timeout: int = 60):
@@ -217,7 +232,7 @@ def test_install(node_factory):
217232
assert r.search_stdout('dependencies installed successfully')
218233
assert r.search_stdout('plugin installed:')
219234
assert r.search_stdout('testplugpass enabled')
220-
check_stderr(r.stderr)
235+
r.check_stderr()
221236
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpass'
222237
print(plugin_path)
223238
assert os.path.exists(plugin_path)
@@ -232,7 +247,7 @@ def test_poetry_install(node_factory):
232247
assert r.search_stdout('dependencies installed successfully')
233248
assert r.search_stdout('plugin installed:')
234249
assert r.search_stdout('testplugpyproj enabled')
235-
check_stderr(r.stderr)
250+
r.check_stderr()
236251
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpyproj'
237252
print(plugin_path)
238253
assert os.path.exists(plugin_path)
@@ -278,7 +293,7 @@ def test_disable_enable(node_factory):
278293
assert r.search_stdout('dependencies installed successfully')
279294
assert r.search_stdout('plugin installed:')
280295
assert r.search_stdout('testplugpass enabled')
281-
check_stderr(r.stderr)
296+
r.check_stderr()
282297
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpass'
283298
print(plugin_path)
284299
assert os.path.exists(plugin_path)

0 commit comments

Comments
 (0)