forked from LBRYCommunity/lbry-sdk
test for wrong linebreaks and improve fix
This commit is contained in:
parent
c498619cca
commit
e436ae7edd
2 changed files with 42 additions and 8 deletions
|
@ -218,10 +218,8 @@ def generate_options(method, indent) -> List[str]:
|
|||
# dont break on -- or docopt will parse as a new option
|
||||
for line_number, line in enumerate(wrapped):
|
||||
if line.strip().startswith('--'):
|
||||
wrapped[line_number-1] += ' ' + line.strip()
|
||||
wrapped[line_number] = ''
|
||||
continue
|
||||
for line in wrapped:
|
||||
lines[-1] = lines[-1] + ' ' + line.strip()
|
||||
else:
|
||||
lines.append(f"{' ' * len(left)} {line}")
|
||||
options.extend(lines)
|
||||
return options
|
||||
|
|
|
@ -13,7 +13,12 @@ def test_kwargs(somevalue=1):
|
|||
|
||||
|
||||
@expander
|
||||
def another_test_kwargs(somevalue=2, repeated=3):
|
||||
def another_test_kwargs(
|
||||
somevalue=1,
|
||||
repeated=2,
|
||||
bad_description=3, # using linebreaks makes docopt very very --angry
|
||||
angry=4
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -45,8 +50,15 @@ class FakeAPI:
|
|||
|
||||
def thing_search(
|
||||
self,
|
||||
**test_and_another_test_kwargs):
|
||||
"""search command doc"""
|
||||
query='a',
|
||||
**test_and_another_test_kwargs) -> Wallet:
|
||||
"""
|
||||
search command doc
|
||||
|
||||
Usage:
|
||||
thing search [--query=<query>]
|
||||
{kwargs}
|
||||
"""
|
||||
|
||||
def thing_delete(self, value1: str, **tx_and_pagination_kwargs) -> Wallet: # deleted thing
|
||||
"""
|
||||
|
@ -287,3 +299,27 @@ class TestGenerator(TestCase):
|
|||
(str) cheese
|
||||
foo bar""")
|
||||
)
|
||||
|
||||
def test_parse_does_not_break_with_two_dashes(self):
|
||||
# breaking with two dashes breaks docopt parsing
|
||||
definitions = get_api_definitions(FakeAPI)
|
||||
self.assertEqual(definitions['commands']['thing_search']['help'], """search command doc
|
||||
|
||||
Usage:
|
||||
thing search [--query=<query>]
|
||||
[--somevalue=<somevalue>] [--repeated=<repeated>]
|
||||
[--bad_description=<bad_description>] [--angry=<angry>]
|
||||
|
||||
Options:
|
||||
--query=<query> : (str) [default: 'a']
|
||||
--somevalue=<somevalue> : (int) [default: 1]
|
||||
--repeated=<repeated> : (int) [default: 2]
|
||||
--bad_description=<bad_description> : (int) using linebreaks makes docopt very very --angry [default: 3]
|
||||
--angry=<angry> : (int) [default: 4]
|
||||
|
||||
Returns:
|
||||
(Wallet)
|
||||
{
|
||||
"id": "wallet_id",
|
||||
"name": "optional wallet name"
|
||||
}""")
|
||||
|
|
Loading…
Reference in a new issue