diff options
author | Ricardo Martincoski <ricardo.martincoski@gmail.com> | 2018-11-16 01:57:26 -0200 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@bootlin.com> | 2018-11-23 22:05:46 +0100 |
commit | 887248d3545bdec263e2fe3013a83939111d3a02 (patch) | |
tree | 93a5be5f736a402166557d0b6e0b5ad3d02361ff /support/testing/tests/package/test_python_click.py | |
parent | 61b4b81c44028910ebfe111b70454b8e193bf85b (diff) | |
download | buildroot-887248d3545bdec263e2fe3013a83939111d3a02.tar.gz buildroot-887248d3545bdec263e2fe3013a83939111d3a02.zip |
support/testing: add python-click 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>
Diffstat (limited to 'support/testing/tests/package/test_python_click.py')
-rw-r--r-- | support/testing/tests/package/test_python_click.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/support/testing/tests/package/test_python_click.py b/support/testing/tests/package/test_python_click.py new file mode 100644 index 0000000000..db57d3aa9f --- /dev/null +++ b/support/testing/tests/package/test_python_click.py @@ -0,0 +1,44 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonClick(TestPythonPackageBase): + sample_scripts = ["tests/package/sample_python_click.py"] + + def run_sample_scripts(self): + cmd = self.interpreter + " sample_python_click.py --help" + output, exit_code = self.emulator.run(cmd) + self.assertIn("Usage:", output[0]) + self.assertEqual(exit_code, 0) + + cmd = self.interpreter + " sample_python_click.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_click.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_click.py" + output, exit_code = self.emulator.run(cmd) + self.assertIn("Usage:", output[0]) + self.assertEqual(exit_code, 2) + + +class TestPythonPy2Click(TestPythonClick): + __test__ = True + config = TestPythonClick.config + \ + """ + BR2_PACKAGE_PYTHON=y + BR2_PACKAGE_PYTHON_CLICK=y + """ + + +class TestPythonPy3Click(TestPythonClick): + __test__ = True + config = TestPythonClick.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_CLICK=y + """ |