mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 00:20:38 -09:00
support/testing: add python-argh tests
Use a simple script to check the basic usage. Since this package provides command line arguments, override run_sample_scripts to call the script with arguments and check the expected output. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
0d896cf007
commit
1bd9e9c199
45
support/testing/tests/package/test_python_argh.py
Normal file
45
support/testing/tests/package/test_python_argh.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from tests.package.test_python import TestPythonPackageBase
|
||||
|
||||
|
||||
class TestPythonArgh(TestPythonPackageBase):
|
||||
config = TestPythonPackageBase.config
|
||||
sample_scripts = ["tests/package/sample_python_argh.py"]
|
||||
|
||||
def run_sample_scripts(self):
|
||||
cmd = self.interpreter + " sample_python_argh.py -h"
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertIn("usage:", output[0])
|
||||
self.assertEqual(exit_code, 0)
|
||||
|
||||
cmd = self.interpreter + " sample_python_argh.py 123"
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertEqual(output[0], "123, False")
|
||||
self.assertEqual(exit_code, 0)
|
||||
|
||||
cmd = self.interpreter + " sample_python_argh.py --bar 456"
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertEqual(output[0], "456, True")
|
||||
self.assertEqual(exit_code, 0)
|
||||
|
||||
cmd = self.interpreter + " sample_python_argh.py"
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertIn("usage:", output[0])
|
||||
self.assertEqual(exit_code, 2)
|
||||
|
||||
|
||||
class TestPythonPy2Argh(TestPythonArgh):
|
||||
__test__ = True
|
||||
config = TestPythonArgh.config + \
|
||||
"""
|
||||
BR2_PACKAGE_PYTHON=y
|
||||
BR2_PACKAGE_PYTHON_ARGH=y
|
||||
"""
|
||||
|
||||
|
||||
class TestPythonPy3Argh(TestPythonArgh):
|
||||
__test__ = True
|
||||
config = TestPythonArgh.config + \
|
||||
"""
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_PYTHON_ARGH=y
|
||||
"""
|
||||
Reference in New Issue
Block a user