forked from useblocks/libpdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cli.py
28 lines (22 loc) · 879 Bytes
/
test_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Initial test cases for CLI."""
import sys
from click.testing import CliRunner
from libpdf.core import main_cli
import pytest
from tests.conftest import PDF_LOREM_IPSUM, PDF_TWO_COLUMNS
@pytest.mark.parametrize(
'path',
[PDF_LOREM_IPSUM, PDF_TWO_COLUMNS],
)
def test_cli_ok(path):
"""Check if CLI exits with code 0 when no errors occur."""
runner = CliRunner()
result = runner.invoke(main_cli, [path, '-o', 'out.yaml', '-f', 'yaml'])
if sys.platform.startswith('win') and path == PDF_TWO_COLUMNS:
# TODO bug on Windows currently for PDF_TWO_COLUMNS:
# UnicodeEncodeError('charmap', '\uf0b7 8 1/2', 0, 1, 'character maps to <undefined>')
assert isinstance(result.exception, UnicodeEncodeError)
assert result.exit_code == 1
else:
assert result.exception is None
assert result.exit_code == 0