blob: a334abce5f6b8f85b69ea6ae3d5c0e8a3435db49 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005import subprocess, unittest
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006from oeqa.sdk.case import OESDKTestCase
7
Brad Bishop19323692019-04-05 15:28:33 -04008from oeqa.utils.subprocesstweak import errors_have_output
9errors_have_output()
10
11class Python2Test(OESDKTestCase):
12 def setUp(self):
13 if not (self.tc.hasHostPackage("nativesdk-python-core") or
14 self.tc.hasHostPackage("python-core-native")):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015 raise unittest.SkipTest("No python package in the SDK")
16
Brad Bishop19323692019-04-05 15:28:33 -040017 def test_python2(self):
18 cmd = "python -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\""
19 output = self._run(cmd)
20 self.assertEqual(output, "Hello, world\n")
21
22class Python3Test(OESDKTestCase):
23 def setUp(self):
24 if not (self.tc.hasHostPackage("nativesdk-python3-core") or
25 self.tc.hasHostPackage("python3-core-native")):
26 raise unittest.SkipTest("No python3 package in the SDK")
27
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 def test_python3(self):
Brad Bishop19323692019-04-05 15:28:33 -040029 cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\""
30 output = self._run(cmd)
31 self.assertEqual(output, "Hello, world\n")