Skip to content

Commit b53c550

Browse files
committed
tests: Add test_castxml_module and test_wheel
1 parent 87a1ac1 commit b53c550

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

tests/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import sys
3+
4+
from contextlib import contextmanager
5+
6+
7+
@contextmanager
8+
def push_argv(argv):
9+
old_argv = sys.argv
10+
sys.argv = argv
11+
yield
12+
sys.argv = old_argv

tests/test_castxml.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
import pytest
3+
4+
import castxml
5+
6+
from . import push_argv
7+
8+
9+
def _run(program, args):
10+
func = getattr(castxml, program)
11+
args = ["%s.py" % program] + args
12+
with push_argv(args), pytest.raises(SystemExit) as excinfo:
13+
func()
14+
assert 0 == excinfo.value.code
15+
16+
17+
def test_castxml_module():
18+
_run("castxml", ["--version"])

tests/test_distribution.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
import os
3+
import pytest
4+
5+
from path import Path
6+
7+
DIST_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../dist'))
8+
9+
10+
def _check_castxml_install(virtualenv, tmpdir):
11+
expected_version = "0.3.4"
12+
13+
for executable_name in ["castxml"]:
14+
output = virtualenv.run(
15+
"%s --version" % executable_name, capture=True).splitlines()[0]
16+
assert output == "%s version %s" % (executable_name, expected_version)
17+
18+
19+
@pytest.mark.skipif(not Path(DIST_DIR).exists(), reason="dist directory does not exist")
20+
def test_wheel(virtualenv, tmpdir):
21+
wheels = Path(DIST_DIR).files(match="*.whl")
22+
if not wheels:
23+
pytest.skip("no wheel available")
24+
assert len(wheels) == 1
25+
print(wheels)
26+
27+
virtualenv.run("pip install %s" % wheels[0])
28+
29+
_check_castxml_install(virtualenv, tmpdir)

0 commit comments

Comments
 (0)