summaryrefslogtreecommitdiffstats
path: root/support/testing/tests/package/test_python_argh.py
blob: de4b4cbe74fbb3931a2df954317dd84cd8783572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
        """
OpenPOWER on IntegriCloud