Commit 9c0a3d22 authored by Ximin Luo's avatar Ximin Luo

presenters: text: fix recursive indentation of headers

parent 07297e67
......@@ -89,5 +89,5 @@ class TextPresenter(Presenter):
def output(self, val, raw=False):
self.print_func(
self.indent(val, self.PREFIX * (self.depth + 0 if raw else -1)),
self.indent(val, self.PREFIX * (self.depth + (0 if raw else -1))),
)
--- archive1.tar
+++ archive2.tar
├── file list
│ @@ -1 +1 @@
│ --rw-r--r-- 0 lamby (1000) lamby (1000) 22 2017-03-19 22:26:58.000000 compressed.gz
│ +-rw-r--r-- 0 lamby (1000) lamby (1000) 33 2017-03-19 22:27:42.000000 compressed.gz
├── compressed.gz
│ ├── metadata
│ │ @@ -1 +1 @@
│ │ -gzip compressed data, max compression, from Unix
│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix
│ ├── compressed
│ │ @@ -1 +1 @@
│ │ -a
│ │ +b
......@@ -29,9 +29,9 @@ from .utils.data import cwd_data, get_data
re_html = re.compile(r'.*<body(?P<body>.*)<div class="footer">', re.MULTILINE | re.DOTALL)
def run(capsys, *args):
def run(capsys, *args, pair=('test1.tar', 'test2.tar')):
with pytest.raises(SystemExit) as exc, cwd_data():
main(args + ('test1.tar', 'test2.tar'))
main(args + pair)
out, err = capsys.readouterr()
assert err == ''
......@@ -39,13 +39,7 @@ def run(capsys, *args):
return out
def run_images(capsys, *args):
with pytest.raises(SystemExit) as exc, cwd_data():
main(args + ('test1.png', 'test2.png'))
out, err = capsys.readouterr()
assert err == ''
assert exc.value.code == 1
return out
return run(capsys, *args, pair=('test1.png', 'test2.png'))
def extract_body(val):
"""
......@@ -65,6 +59,11 @@ def test_text_option_is_default(capsys):
assert out == get_data('output.txt')
def test_text_proper_indentation(capsys):
out = run(capsys, pair=('archive1.tar', 'archive2.tar'))
assert out == get_data('archive12.diff.txt')
def test_text_option_color(capsys):
out = run(capsys, '--text-color=always')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment