Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | import os |
| 2 | import shutil |
| 3 | import unittest |
| 4 | |
| 5 | from oeqa.core.utils.path import remove_safe |
| 6 | from oeqa.sdk.case import OESDKTestCase |
| 7 | |
| 8 | class PythonTest(OESDKTestCase): |
| 9 | @classmethod |
| 10 | def setUpClass(self): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | if not (self.tc.hasHostPackage("nativesdk-python") or |
| 12 | self.tc.hasHostPackage("python-native")): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | raise unittest.SkipTest("No python package in the SDK") |
| 14 | |
| 15 | for f in ['test.py']: |
| 16 | shutil.copyfile(os.path.join(self.tc.files_dir, f), |
| 17 | os.path.join(self.tc.sdk_dir, f)) |
| 18 | |
| 19 | def test_python_exists(self): |
| 20 | self._run('which python') |
| 21 | |
| 22 | def test_python_stdout(self): |
| 23 | output = self._run('python %s/test.py' % self.tc.sdk_dir) |
| 24 | self.assertEqual(output.strip(), "the value of a is 0.01", msg="Incorrect output: %s" % output) |
| 25 | |
| 26 | def test_python_testfile(self): |
| 27 | self._run('ls /tmp/testfile.python') |
| 28 | |
| 29 | @classmethod |
| 30 | def tearDownClass(self): |
| 31 | remove_safe("%s/test.py" % self.tc.sdk_dir) |
| 32 | remove_safe("/tmp/testfile.python") |