36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from magicli.magicli import format_block
|
|
from unittest import mock
|
|
|
|
|
|
def get_terminal_size():
|
|
return (80, 20)
|
|
|
|
def test_empty_lines():
|
|
with mock.patch('os.get_terminal_size', get_terminal_size):
|
|
min_column_width=5
|
|
indent=2
|
|
gap=2
|
|
assert format_block([['', '']],
|
|
min_column_width=min_column_width,
|
|
indent=indent,
|
|
gap=gap
|
|
) == ' '*(min_column_width+indent+gap)
|
|
|
|
def test_two_lines():
|
|
with mock.patch('os.get_terminal_size', get_terminal_size):
|
|
assert format_block([
|
|
['--help', 'Show help message.'],
|
|
['-v, --version', 'Show version information.'],
|
|
], min_column_width=0) == \
|
|
' --help Show help message.\n' +\
|
|
' -v, --version Show version information.'
|
|
|
|
def test_two_lines_with_minimum_width():
|
|
with mock.patch('os.get_terminal_size', get_terminal_size):
|
|
assert format_block([
|
|
['--help', 'Show help message.'],
|
|
['-v, --version', 'Show version information.'],
|
|
], min_column_width=20) == \
|
|
' --help Show help message.\n' +\
|
|
' -v, --version Show version information.'
|