mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2025-02-13 08:54:23 +01:00
Fix crash when no commands are available
This commit is contained in:
parent
6c0dfd2263
commit
262038e95d
2 changed files with 10 additions and 0 deletions
|
@ -93,6 +93,9 @@ class RootCommand(Command):
|
||||||
'Fimfarchive, ensuring that history is preseved.\n\n',
|
'Fimfarchive, ensuring that history is preseved.\n\n',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if not self.commands:
|
||||||
|
return ''.join(text).strip()
|
||||||
|
|
||||||
commands = sorted(cmd for cmd in self.commands.keys())
|
commands = sorted(cmd for cmd in self.commands.keys())
|
||||||
adjust = max(len(cmd) for cmd in commands) + 2
|
adjust = max(len(cmd) for cmd in commands) + 2
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,13 @@ class TestRootCommanad():
|
||||||
assert "failure Command that returns 1." in doc
|
assert "failure Command that returns 1." in doc
|
||||||
assert "truncated documentation line" not in doc
|
assert "truncated documentation line" not in doc
|
||||||
|
|
||||||
|
def test_root_usage_without_commands(self, root):
|
||||||
|
"""
|
||||||
|
Tests usage contains text when no commands are available.
|
||||||
|
"""
|
||||||
|
type(root).commands = dict()
|
||||||
|
assert root.usage.strip()
|
||||||
|
|
||||||
def test_root_call_without_args(self, root, success, failure):
|
def test_root_call_without_args(self, root, success, failure):
|
||||||
"""
|
"""
|
||||||
Tests `SystemExit` is raised if called without arguments.
|
Tests `SystemExit` is raised if called without arguments.
|
||||||
|
|
Loading…
Reference in a new issue