2
0
Эх сурвалжийг харах

add test for dedent strip

Isaac 2 жил өмнө
parent
commit
43c532bc57

+ 4 - 0
borgmatic/commands/completion.py

@@ -143,6 +143,10 @@ def exact_options_completion(action: Action):
 
 
 
 
 def dedent_strip_as_tuple(string: str):
 def dedent_strip_as_tuple(string: str):
+    '''
+    Dedent a string, then strip it to avoid requiring your first line to have content, then return a tuple of the string.
+    Makes it easier to write multiline strings for completions when you join them with a tuple.
+    '''
     return (dedent(string).strip('\n'),)
     return (dedent(string).strip('\n'),)
 
 
 
 

+ 10 - 0
tests/unit/commands/test_completions.py

@@ -5,6 +5,7 @@ from typing import Tuple
 import pytest
 import pytest
 
 
 from borgmatic.commands.completion import (
 from borgmatic.commands.completion import (
+    dedent_strip_as_tuple,
     exact_options_completion,
     exact_options_completion,
     has_choice_options,
     has_choice_options,
     has_exact_options,
     has_exact_options,
@@ -131,3 +132,12 @@ def test_produce_exact_options_completion(action: Action, option_type: OptionTyp
 
 
     except ValueError as value_error:
     except ValueError as value_error:
         assert False, f'exact_options_completion raised ValueError: {value_error}'
         assert False, f'exact_options_completion raised ValueError: {value_error}'
+
+
+def test_dedent_strip_as_tuple():
+    dedent_strip_as_tuple(
+        '''
+        a
+        b
+    '''
+    )