1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7import glob
8import os
9import shutil
10from oeqa.utils.commands import bitbake, get_test_layer
11from oeqa.selftest.case import OESelftestTestCase
12
13class Pseudo(OESelftestTestCase):
14
15    def test_pseudo_pyc_creation(self):
16        self.write_config("")
17
18        metaselftestpath = get_test_layer()
19        pycache_path = os.path.join(metaselftestpath, 'lib/__pycache__')
20        if os.path.exists(pycache_path):
21            shutil.rmtree(pycache_path)
22
23        bitbake('pseudo-pyc-test -c install')
24
25        test1_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test1.*.pyc')))
26        self.assertTrue(test1_pyc_present, 'test1 pyc file missing, should be created outside of pseudo context.')
27
28        test2_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test2.*.pyc')))
29        self.assertFalse(test2_pyc_present, 'test2 pyc file present, should not be created in pseudo context.')
30