test_python_argh.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from tests.package.test_python import TestPythonPackageBase
  2. class TestPythonArgh(TestPythonPackageBase):
  3. config = TestPythonPackageBase.config
  4. sample_scripts = ["tests/package/sample_python_argh.py"]
  5. def run_sample_scripts(self):
  6. cmd = self.interpreter + " sample_python_argh.py -h"
  7. output, exit_code = self.emulator.run(cmd)
  8. self.assertIn("usage:", output[0])
  9. self.assertEqual(exit_code, 0)
  10. cmd = self.interpreter + " sample_python_argh.py 123"
  11. output, exit_code = self.emulator.run(cmd)
  12. self.assertEqual(output[0], "123, False")
  13. self.assertEqual(exit_code, 0)
  14. cmd = self.interpreter + " sample_python_argh.py --bar 456"
  15. output, exit_code = self.emulator.run(cmd)
  16. self.assertEqual(output[0], "456, True")
  17. self.assertEqual(exit_code, 0)
  18. cmd = self.interpreter + " sample_python_argh.py"
  19. output, exit_code = self.emulator.run(cmd)
  20. self.assertIn("usage:", output[0])
  21. self.assertEqual(exit_code, 2)
  22. class TestPythonPy2Argh(TestPythonArgh):
  23. __test__ = True
  24. config = TestPythonArgh.config + \
  25. """
  26. BR2_PACKAGE_PYTHON=y
  27. BR2_PACKAGE_PYTHON_ARGH=y
  28. """
  29. class TestPythonPy3Argh(TestPythonArgh):
  30. __test__ = True
  31. config = TestPythonArgh.config + \
  32. """
  33. BR2_PACKAGE_PYTHON3=y
  34. BR2_PACKAGE_PYTHON_ARGH=y
  35. """