Debian Codegraph @

python-scripts/daps-xmlwellformed/tests/test_cli.py

raw
1 from pathlib import Path
2 import sys
3
4 import pytest
5
6 # "dxwf" is the abbreviated name for daps-xmlwellformed
7 # We can't import a name with a "-" so we use a link here:
8 import dxwf
9
10
11 ROOTDIR = Path(__file__).parent.parent
12 BINDIR = ROOTDIR / "bin"
13 PROG = [p for p in BINDIR.glob("daps*") if p.suffix != '.xsl'][0]
14
15
16
17 def test_help(capsys):
18 # given
19 # n/a
20
21 # when
22 with pytest.raises(SystemExit):
23 dxwf.main(["prog", "--help"])
24
25 # then
26 assert capsys.readouterr()
27
28
29 def test_invalid(capsys):
30 # given
31 # n/a
32
33 # when
34 with pytest.raises(SystemExit):
35 dxwf.main(["prog", "--asdf"])
36
37 # then
38 assert capsys.readouterr()
39
40
41 def test_version(capsys):
42 # given
43 # n/a
44
45 # when
46 with pytest.raises(SystemExit):
47 dxwf.main(["--version"])
48 captured = capsys.readouterr()
49
50 # then
51 assert captured.out.rsplit()[-1] == dxwf.__version__