Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | import subprocess, unittest |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 6 | from oeqa.sdk.case import OESDKTestCase |
| 7 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 8 | from oeqa.utils.subprocesstweak import errors_have_output |
| 9 | errors_have_output() |
| 10 | |
| 11 | class Python2Test(OESDKTestCase): |
| 12 | def setUp(self): |
| 13 | if not (self.tc.hasHostPackage("nativesdk-python-core") or |
| 14 | self.tc.hasHostPackage("python-core-native")): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | raise unittest.SkipTest("No python package in the SDK") |
| 16 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 17 | 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 | |
| 22 | class 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | def test_python3(self): |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" |
| 30 | output = self._run(cmd) |
| 31 | self.assertEqual(output, "Hello, world\n") |