summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-09 09:27:24 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-09 13:54:12 +0000
commitc154eba9aa8e7d780ce2c5a18cbc0756a30850d1 (patch)
tree65c4941f07a033a58e15dff8af22588e25d92702 /meta/lib/oeqa
parentfda06b441655cfa4e5f93e8f5587f27aa3610bb8 (diff)
downloadopenembedded-core-c154eba9aa8e7d780ce2c5a18cbc0756a30850d1.tar.gz
selftest/recipetool: Factor tomllib test to a function
As more tests start to need this codeblock, factor it into a common function. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py65
1 files changed, 20 insertions, 45 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 39114c6762..780e25b6c8 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -28,6 +28,16 @@ def tearDownModule():
runCmd('rm -rf %s' % templayerdir)
+def needTomllib(test):
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ try:
+ import tomllib
+ except ImportError:
+ try:
+ import tomli
+ except ImportError:
+ test.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+
class RecipetoolBase(devtool.DevtoolTestCase):
def setUpLocal(self):
@@ -554,15 +564,8 @@ class RecipetoolCreateTests(RecipetoolBase):
self._test_recipe_contents(recipefile, checkvars, inherits)
def test_recipetool_create_python3_pep517_setuptools_build_meta(self):
- # This test require python 3.11 or above for the tomllib module
- # or tomli module to be installed
- try:
- import tomllib
- except ImportError:
- try:
- import tomli
- except ImportError:
- self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ needTomllib(self)
# Test creating python3 package from tarball (using setuptools.build_meta class)
temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -583,15 +586,8 @@ class RecipetoolCreateTests(RecipetoolBase):
self._test_recipe_contents(recipefile, checkvars, inherits)
def test_recipetool_create_python3_pep517_poetry_core_masonry_api(self):
- # This test require python 3.11 or above for the tomllib module
- # or tomli module to be installed
- try:
- import tomllib
- except ImportError:
- try:
- import tomli
- except ImportError:
- self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ needTomllib(self)
# Test creating python3 package from tarball (using poetry.core.masonry.api class)
temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -612,15 +608,8 @@ class RecipetoolCreateTests(RecipetoolBase):
self._test_recipe_contents(recipefile, checkvars, inherits)
def test_recipetool_create_python3_pep517_flit_core_buildapi(self):
- # This test require python 3.11 or above for the tomllib module
- # or tomli module to be installed
- try:
- import tomllib
- except ImportError:
- try:
- import tomli
- except ImportError:
- self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ needTomllib(self)
# Test creating python3 package from tarball (using flit_core.buildapi class)
temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -641,15 +630,8 @@ class RecipetoolCreateTests(RecipetoolBase):
self._test_recipe_contents(recipefile, checkvars, inherits)
def test_recipetool_create_python3_pep517_hatchling(self):
- # This test require python 3.11 or above for the tomllib module
- # or tomli module to be installed
- try:
- import tomllib
- except ImportError:
- try:
- import tomli
- except ImportError:
- self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ needTomllib(self)
# Test creating python3 package from tarball (using hatchling class)
temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -671,15 +653,8 @@ class RecipetoolCreateTests(RecipetoolBase):
self._test_recipe_contents(recipefile, checkvars, inherits)
def test_recipetool_create_python3_pep517_maturin(self):
- # This test require python 3.11 or above for the tomllib module
- # or tomli module to be installed
- try:
- import tomllib
- except ImportError:
- try:
- import tomli
- except ImportError:
- self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
+ # This test require python 3.11 or above for the tomllib module or tomli module to be installed
+ needTomllib(self)
# Test creating python3 package from tarball (using maturin class)
temprecipe = os.path.join(self.tempdir, 'recipe')