tests: show that the examples still work when directly invoked

Since Ic4a124a5cbe2bd24c56e4565d27d313fe4da703f, there was no automated
test which would check if the generated examples *really* work. When I
was playing with this, I managed to break it at least once (especially
when working on overriding sys.args, i.e.,
I53833a5513abae0abd57065a49c0f357890e0820).

This now requires an equivalent of `pip install` before the tests can be
run.

Change-Id: I595a3efe29b3ee13800c5cb71f28a5f370988617
This commit is contained in:
Jan Kundrát
2020-06-05 15:28:58 +02:00
parent 1009b44d2a
commit 7f816eb6e7

View File

@@ -3,6 +3,7 @@
from pathlib import Path
import os
import pytest
import subprocess
from gnpy.tools.cli_examples import transmission_main_example, path_requests_run
SRC_ROOT = Path(__file__).parent.parent
@@ -22,3 +23,13 @@ def test_example_invocation(capfdbinary, output, handler, args):
captured = capfdbinary.readouterr()
assert captured.out == expected
assert captured.err == b''
@pytest.mark.parametrize('program', ('gnpy-transmission-example', 'gnpy-path-request'))
def test_run_wrapper(program):
'''Ensure that our wrappers really, really work'''
proc = subprocess.run((program, '--help'), stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True, universal_newlines=True)
assert proc.stderr == ''
assert 'https://github.com/telecominfraproject/oopt-gnpy' in proc.stdout.lower()
assert 'https://gnpy.readthedocs.io/' in proc.stdout.lower()