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:55:06 +0000
commitf9ed2bdfdb2bc1b039d00b5fd545e094438eb235 (patch)
tree7a3e90b6a0540e398fa3b47f6504329ec182fc5e /meta/lib/oeqa
parentdf0a2575ec54dd20061092d0a8fba93de294da04 (diff)
downloadpoky-f9ed2bdfdb2bc1b039d00b5fd545e094438eb235.tar.gz
selftest/recipetool: Factor tomllib test to a function
As more tests start to need this codeblock, factor it into a common function. (From OE-Core rev: c154eba9aa8e7d780ce2c5a18cbc0756a30850d1) 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():
28 runCmd('rm -rf %s' % templayerdir) 28 runCmd('rm -rf %s' % templayerdir)
29 29
30 30
31def needTomllib(test):
32 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
33 try:
34 import tomllib
35 except ImportError:
36 try:
37 import tomli
38 except ImportError:
39 test.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
40
31class RecipetoolBase(devtool.DevtoolTestCase): 41class RecipetoolBase(devtool.DevtoolTestCase):
32 42
33 def setUpLocal(self): 43 def setUpLocal(self):
@@ -554,15 +564,8 @@ class RecipetoolCreateTests(RecipetoolBase):
554 self._test_recipe_contents(recipefile, checkvars, inherits) 564 self._test_recipe_contents(recipefile, checkvars, inherits)
555 565
556 def test_recipetool_create_python3_pep517_setuptools_build_meta(self): 566 def test_recipetool_create_python3_pep517_setuptools_build_meta(self):
557 # This test require python 3.11 or above for the tomllib module 567 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
558 # or tomli module to be installed 568 needTomllib(self)
559 try:
560 import tomllib
561 except ImportError:
562 try:
563 import tomli
564 except ImportError:
565 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
566 569
567 # Test creating python3 package from tarball (using setuptools.build_meta class) 570 # Test creating python3 package from tarball (using setuptools.build_meta class)
568 temprecipe = os.path.join(self.tempdir, 'recipe') 571 temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -583,15 +586,8 @@ class RecipetoolCreateTests(RecipetoolBase):
583 self._test_recipe_contents(recipefile, checkvars, inherits) 586 self._test_recipe_contents(recipefile, checkvars, inherits)
584 587
585 def test_recipetool_create_python3_pep517_poetry_core_masonry_api(self): 588 def test_recipetool_create_python3_pep517_poetry_core_masonry_api(self):
586 # This test require python 3.11 or above for the tomllib module 589 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
587 # or tomli module to be installed 590 needTomllib(self)
588 try:
589 import tomllib
590 except ImportError:
591 try:
592 import tomli
593 except ImportError:
594 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
595 591
596 # Test creating python3 package from tarball (using poetry.core.masonry.api class) 592 # Test creating python3 package from tarball (using poetry.core.masonry.api class)
597 temprecipe = os.path.join(self.tempdir, 'recipe') 593 temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -612,15 +608,8 @@ class RecipetoolCreateTests(RecipetoolBase):
612 self._test_recipe_contents(recipefile, checkvars, inherits) 608 self._test_recipe_contents(recipefile, checkvars, inherits)
613 609
614 def test_recipetool_create_python3_pep517_flit_core_buildapi(self): 610 def test_recipetool_create_python3_pep517_flit_core_buildapi(self):
615 # This test require python 3.11 or above for the tomllib module 611 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
616 # or tomli module to be installed 612 needTomllib(self)
617 try:
618 import tomllib
619 except ImportError:
620 try:
621 import tomli
622 except ImportError:
623 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
624 613
625 # Test creating python3 package from tarball (using flit_core.buildapi class) 614 # Test creating python3 package from tarball (using flit_core.buildapi class)
626 temprecipe = os.path.join(self.tempdir, 'recipe') 615 temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -641,15 +630,8 @@ class RecipetoolCreateTests(RecipetoolBase):
641 self._test_recipe_contents(recipefile, checkvars, inherits) 630 self._test_recipe_contents(recipefile, checkvars, inherits)
642 631
643 def test_recipetool_create_python3_pep517_hatchling(self): 632 def test_recipetool_create_python3_pep517_hatchling(self):
644 # This test require python 3.11 or above for the tomllib module 633 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
645 # or tomli module to be installed 634 needTomllib(self)
646 try:
647 import tomllib
648 except ImportError:
649 try:
650 import tomli
651 except ImportError:
652 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
653 635
654 # Test creating python3 package from tarball (using hatchling class) 636 # Test creating python3 package from tarball (using hatchling class)
655 temprecipe = os.path.join(self.tempdir, 'recipe') 637 temprecipe = os.path.join(self.tempdir, 'recipe')
@@ -671,15 +653,8 @@ class RecipetoolCreateTests(RecipetoolBase):
671 self._test_recipe_contents(recipefile, checkvars, inherits) 653 self._test_recipe_contents(recipefile, checkvars, inherits)
672 654
673 def test_recipetool_create_python3_pep517_maturin(self): 655 def test_recipetool_create_python3_pep517_maturin(self):
674 # This test require python 3.11 or above for the tomllib module 656 # This test require python 3.11 or above for the tomllib module or tomli module to be installed
675 # or tomli module to be installed 657 needTomllib(self)
676 try:
677 import tomllib
678 except ImportError:
679 try:
680 import tomli
681 except ImportError:
682 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
683 658
684 # Test creating python3 package from tarball (using maturin class) 659 # Test creating python3 package from tarball (using maturin class)
685 temprecipe = os.path.join(self.tempdir, 'recipe') 660 temprecipe = os.path.join(self.tempdir, 'recipe')