Skip to content

Commit 6d142df

Browse files
committed
pytest: add multiline help test.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 44093f0 commit 6d142df

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Diff for: tests/plugins/multiline-help.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
from pyln.client import Plugin, Millisatoshi
3+
4+
5+
plugin = Plugin()
6+
7+
8+
@plugin.method("helpme")
9+
def helpme(plugin, msat: Millisatoshi):
10+
"""This is a message which consumes multiple lines and thus should
11+
be well-formatted by lightning-cli help
12+
13+
"""
14+
return {'help': msat}
15+
16+
17+
plugin.run()

Diff for: tests/test_misc.py

+22
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,28 @@ def test_cli(node_factory):
11481148
assert [l for l in lines if not re.search(r'^help\[[0-9]*\].', l)] == ['format-hint=simple']
11491149

11501150

1151+
def test_cli_multiline_help(node_factory):
1152+
l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/multiline-help.py')})
1153+
1154+
out = subprocess.check_output(['cli/lightning-cli',
1155+
'--network={}'.format(TEST_NETWORK),
1156+
'--lightning-dir={}'
1157+
.format(l1.daemon.lightning_dir),
1158+
'help']).decode('utf-8')
1159+
assert ("helpme msat \n"
1160+
" This is a message which consumes multiple lines and thus should\n"
1161+
" be well-formatted by lightning-cli help\n" in out)
1162+
1163+
out = subprocess.check_output(['cli/lightning-cli',
1164+
'--network={}'.format(TEST_NETWORK),
1165+
'--lightning-dir={}'
1166+
.format(l1.daemon.lightning_dir),
1167+
'help', 'helpme']).decode('utf-8')
1168+
assert out == ("helpme msat \n"
1169+
" This is a message which consumes multiple lines and thus should\n"
1170+
" be well-formatted by lightning-cli help\n")
1171+
1172+
11511173
def test_cli_commando(node_factory):
11521174
l1, l2 = node_factory.line_graph(2, fundchannel=False,
11531175
opts={'log-level': 'io'})

0 commit comments

Comments
 (0)