提交 835d2268 编写于 作者: HansBug's avatar HansBug 😆

test(hansbug): add output information for exitcode check in cli test

上级 db7cd6f8
......@@ -30,7 +30,8 @@ class TestEntryCliExport:
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.t1'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 240
......@@ -42,7 +43,8 @@ class TestEntryCliExport:
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 240
assert os.path.exists('t2.btv')
......@@ -60,7 +62,8 @@ class TestEntryCliExport:
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.t[23]'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('t1.btv')
assert os.path.exists('t2.btv')
assert os.path.getsize('t2.btv') < 290
......@@ -78,7 +81,8 @@ class TestEntryCliExport:
with pytest.warns(None):
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*', '-r'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 2170
assert os.path.exists('t2.btv')
......@@ -98,7 +102,8 @@ class TestEntryCliExport:
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*',
'-r', '-c', 'zlib'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 2170
assert os.path.exists('t2.btv')
......@@ -119,7 +124,8 @@ class TestEntryCliExport:
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*',
'-c', 'gzip'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 220
assert os.path.exists('t2.btv')
......@@ -140,7 +146,8 @@ class TestEntryCliExport:
'-c', 'test.entry.cli.test_export._my_compress:test.entry.cli.test_export._my_decompress'
])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 330
assert os.path.exists('t2.btv')
......@@ -167,7 +174,8 @@ class TestEntryCliExport:
'-o', 'subpath/t3.btv',
])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('subpath/t1.btv')
assert os.path.getsize('subpath/t1.btv') < 290
assert os.path.exists('subpath/t2.btv')
......@@ -190,7 +198,8 @@ class TestEntryCliExport:
'-d', 'subpath',
])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('subpath/t1.btv')
assert os.path.getsize('subpath/t1.btv') < 290
assert os.path.exists('subpath/t2.btv')
......@@ -210,7 +219,8 @@ class TestEntryCliExport:
'-d', 'subpath',
])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('subpath/t1.btv')
assert os.path.exists('subpath/t2.btv')
assert os.path.getsize('subpath/t2.btv') < 290
......@@ -229,7 +239,8 @@ class TestEntryCliExport:
'-o', 'ppp.btv'
])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('t1.btv')
assert not os.path.exists('t2.btv')
assert os.path.exists('ppp.btv')
......
......@@ -36,7 +36,8 @@ class TestEntryCliGraph:
'-o', 'test_graph.svg', '-o', 'test_graph.gv'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 7000
assert os.path.exists('test_graph.gv')
......@@ -52,7 +53,8 @@ class TestEntryCliGraph:
'-o', 'test_graph.svg', '-o', 'test_graph.gv', '-O'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('test_graph.svg')
assert not os.path.exists('test_graph.gv')
assert len(result.output) <= 2500
......@@ -66,7 +68,8 @@ class TestEntryCliGraph:
args=['graph', '-t', 'test.entry.cli.test_graph.t[12]', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 13000
......@@ -76,7 +79,8 @@ class TestEntryCliGraph:
args=['graph', '-t', 'test.entry.cli.test_graph.*', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 17500
......@@ -92,7 +96,8 @@ class TestEntryCliGraph:
args=['graph', '-t', 'g1.bg', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 6500
......@@ -109,7 +114,8 @@ class TestEntryCliGraph:
args=['graph', '-t', '*.bg', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 17500
......@@ -122,7 +128,8 @@ class TestEntryCliGraph:
args=['graph', '-t', 'test.entry.cli.test_graph.t1', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 13000
......@@ -135,7 +142,8 @@ class TestEntryCliGraph:
args=['graph', '-t', 'test.entry.cli.test_graph.t1', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 6500
......@@ -149,7 +157,8 @@ class TestEntryCliGraph:
'-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 12000
......@@ -162,7 +171,8 @@ class TestEntryCliGraph:
'-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
import shutil
shutil.copy('test_graph.svg', os.path.join(_p, 'test_graph.svg'))
......@@ -179,7 +189,8 @@ class TestEntryCliGraph:
'-t', 'first title', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 16500
......@@ -196,7 +207,8 @@ class TestEntryCliGraph:
'-c', 'bgcolor=#ffffff00', '-O'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert len(result.output) <= 6000
assert '#ffffff00' in result.output
......@@ -207,7 +219,9 @@ class TestEntryCliGraph:
'-c', 'bgcolor#ffffff00', '-O'],
)
assert result.exit_code != 0
assert result.exit_code != 0, f'The running expected to raise RuntimeError ' \
f'but not actually (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert "Configuration should be KEY=VALUE, but 'bgcolor#ffffff00' found." in result.output
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
......@@ -227,6 +241,7 @@ class TestEntryCliGraph:
args=['graph', '-t', 'g1.bg', '-o', 'test_graph.svg'],
)
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 1000
......@@ -11,6 +11,7 @@ class TestEntryCliVersion:
runner = CliRunner()
result = runner.invoke(treevalue_cli, args=['-v'])
assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert __TITLE__.lower() in result.stdout.lower()
assert __VERSION__.lower() in result.stdout.lower()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册