pytest: refactor reckless check_stderr
What changed, and why it matters
This commit is a minor internal cleanup of a test helper. It moves an existing stderr-checking function into a class method and slightly expands the list of harmless warning strings that tests ignore. It does not change any production code, network behavior, or security logic.
No action required; this is a test-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors check_stderr() from a module-level function in tests/test_reckless.py into a method RecklessResult.check_stderr(). The method raises an exception if any stderr line is not in an allow-list of expected warnings (pip/npm notices, deprecation warnings, virtualenv creation, missing config file, and a confirmation prompt). Three call sites are updated from check_stderr(r.stderr) to r.check_stderr(). No runtime or protocol code is modified.
Changed components
tests/test_reckless.pyInspect captured patch +18 / −3
diff --git a/tests/test_reckless.py b/tests/test_reckless.py
index 1a223f40..229c8d56 100644
--- a/tests/test_reckless.py
+++ b/tests/test_reckless.py
@@ -111,6 +111,21 @@ class RecklessResult:
matching.append(line)
return matching
+ def check_stderr(self):
+ def output_okay(out):
+ for warning in ['[notice]', 'WARNING:', 'npm WARN',
+ 'npm notice', 'DEPRECATION:', 'Creating virtualenv',
+ 'config file not found:', 'press [Y]']:
+ if out.startswith(warning):
+ return True
+ return False
+ for e in self.stderr:
+ if len(e) < 1:
+ continue
+ # Don't err on verbosity from pip, npm
+ if not output_okay(e):
+ raise Exception(f'reckless stderr contains `{e}`')
+
def reckless(cmds: list, dir: PosixPath = None,
autoconfirm=True, timeout: int = 60):
@@ -217,7 +232,7 @@ def test_install(node_factory):
assert r.search_stdout('dependencies installed successfully')
assert r.search_stdout('plugin installed:')
assert r.search_stdout('testplugpass enabled')
- check_stderr(r.stderr)
+ r.check_stderr()
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpass'
print(plugin_path)
assert os.path.exists(plugin_path)
@@ -232,7 +247,7 @@ def test_poetry_install(node_factory):
assert r.search_stdout('dependencies installed successfully')
assert r.search_stdout('plugin installed:')
assert r.search_stdout('testplugpyproj enabled')
- check_stderr(r.stderr)
+ r.check_stderr()
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpyproj'
print(plugin_path)
assert os.path.exists(plugin_path)
@@ -278,7 +293,7 @@ def test_disable_enable(node_factory):
assert r.search_stdout('dependencies installed successfully')
assert r.search_stdout('plugin installed:')
assert r.search_stdout('testplugpass enabled')
- check_stderr(r.stderr)
+ r.check_stderr()
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpass'
print(plugin_path)
assert os.path.exists(plugin_path)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.