mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
dvc: add trailing newline in --show-md (#4124)
To finalize md table. Fixes #4123
This commit is contained in:
+7
-1
@@ -91,7 +91,7 @@ def table(header, rows, markdown=False):
|
||||
if not rows and not markdown:
|
||||
return ""
|
||||
|
||||
return tabulate(
|
||||
ret = tabulate(
|
||||
rows,
|
||||
header,
|
||||
tablefmt="github" if markdown else "plain",
|
||||
@@ -100,6 +100,12 @@ def table(header, rows, markdown=False):
|
||||
missingval="None",
|
||||
)
|
||||
|
||||
if markdown:
|
||||
# NOTE: md table is incomplete without the trailing newline
|
||||
ret += "\n"
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def format_dict(d):
|
||||
ret = {}
|
||||
|
||||
@@ -114,7 +114,7 @@ def test_no_changes(mocker, caplog):
|
||||
|
||||
|
||||
def test_show_md_empty():
|
||||
assert _show_md({}) == ("| Status | Path |\n" "|----------|--------|")
|
||||
assert _show_md({}) == ("| Status | Path |\n|----------|--------|\n")
|
||||
|
||||
|
||||
def test_show_md():
|
||||
@@ -138,5 +138,5 @@ def test_show_md():
|
||||
"| deleted | data{sep}bar |\n"
|
||||
"| deleted | data{sep}foo |\n"
|
||||
"| deleted | zoo |\n"
|
||||
"| modified | file |"
|
||||
"| modified | file |\n"
|
||||
).format(sep=os.path.sep)
|
||||
|
||||
@@ -171,7 +171,8 @@ def test_metrics_diff_markdown_empty():
|
||||
assert _show_diff({}, markdown=True) == textwrap.dedent(
|
||||
"""\
|
||||
| Path | Metric | Value | Change |
|
||||
|--------|----------|---------|----------|"""
|
||||
|--------|----------|---------|----------|
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@@ -191,7 +192,8 @@ def test_metrics_diff_markdown():
|
||||
|--------------|----------|---------|--------------------|
|
||||
| metrics.yaml | a.b.c | 2 | 1 |
|
||||
| metrics.yaml | a.d.e | 4 | 1 |
|
||||
| metrics.yaml | x.b | 6 | diff not supported |"""
|
||||
| metrics.yaml | x.b | 6 | diff not supported |
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -129,7 +129,8 @@ def test_params_diff_markdown_empty():
|
||||
assert _show_diff({}, markdown=True) == textwrap.dedent(
|
||||
"""\
|
||||
| Path | Param | Old | New |
|
||||
|--------|---------|-------|-------|"""
|
||||
|--------|---------|-------|-------|
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@@ -149,7 +150,8 @@ def test_params_diff_markdown():
|
||||
|-------------|---------|-------|-------|
|
||||
| params.yaml | a.b.c | 1 | None |
|
||||
| params.yaml | a.d.e | None | 4 |
|
||||
| params.yaml | x.b | 5 | 6 |"""
|
||||
| params.yaml | x.b | 5 | 6 |
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user