diff options
Diffstat (limited to 'support/testing/tests')
-rw-r--r-- | support/testing/tests/package/sample_python_click.py | 12 | ||||
-rw-r--r-- | support/testing/tests/package/test_python_click.py | 44 |
2 files changed, 56 insertions, 0 deletions
diff --git a/support/testing/tests/package/sample_python_click.py b/support/testing/tests/package/sample_python_click.py new file mode 100644 index 0000000000..759868d087 --- /dev/null +++ b/support/testing/tests/package/sample_python_click.py @@ -0,0 +1,12 @@ +import click + + +@click.command() +@click.argument("foo") +@click.option("--bar", is_flag=True, help="help for bar") +def main(foo, bar): + click.echo("{}, {}".format(foo, bar)) + + +if __name__ == '__main__': + main() 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 + """ |