diff options
Diffstat (limited to 'external/poky/meta/lib/oeqa/sdk/cases/python.py')
-rw-r--r-- | external/poky/meta/lib/oeqa/sdk/cases/python.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/external/poky/meta/lib/oeqa/sdk/cases/python.py b/external/poky/meta/lib/oeqa/sdk/cases/python.py index bd5f1f67..a334abce 100644 --- a/external/poky/meta/lib/oeqa/sdk/cases/python.py +++ b/external/poky/meta/lib/oeqa/sdk/cases/python.py @@ -1,17 +1,31 @@ +# +# SPDX-License-Identifier: MIT +# + import subprocess, unittest from oeqa.sdk.case import OESDKTestCase -class PythonTest(OESDKTestCase): - @classmethod - def setUpClass(self): - if not (self.tc.hasHostPackage("nativesdk-python3") or - self.tc.hasHostPackage("python3-native")): +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class Python2Test(OESDKTestCase): + def setUp(self): + if not (self.tc.hasHostPackage("nativesdk-python-core") or + self.tc.hasHostPackage("python-core-native")): raise unittest.SkipTest("No python package in the SDK") + def test_python2(self): + cmd = "python -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" + output = self._run(cmd) + self.assertEqual(output, "Hello, world\n") + +class Python3Test(OESDKTestCase): + def setUp(self): + if not (self.tc.hasHostPackage("nativesdk-python3-core") or + self.tc.hasHostPackage("python3-core-native")): + raise unittest.SkipTest("No python3 package in the SDK") + def test_python3(self): - try: - cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" - output = self._run(cmd) - self.assertEqual(output, "Hello, world\n") - except subprocess.CalledProcessError as e: - self.fail("Unexpected exit %d (output %s)" % (e.returncode, e.output)) + cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" + output = self._run(cmd) + self.assertEqual(output, "Hello, world\n") |