diff mbox series

[16/23] oeqa/sdk/maturin: no need for a setupClass, merge code into test

Message ID 20250510084400.269726-16-ross.burton@arm.com
State New
Headers show
Series [01/23] buildtools-tarball: fix default_cases assignment | expand

Commit Message

Ross Burton May 10, 2025, 8:43 a.m. UTC
There's no need to copy files inside setUpClass() when there's only one
test function that uses it. Just do all of the test inside the test.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oeqa/sdk/cases/maturin.py | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py
index 83d13c4ec59..e3e8edc7819 100644
--- a/meta/lib/oeqa/sdk/cases/maturin.py
+++ b/meta/lib/oeqa/sdk/cases/maturin.py
@@ -30,17 +30,6 @@  class MaturinTest(OESDKTestCase):
         self.assertIn(expected, output)
 
 class MaturinDevelopTest(OESDKTestCase):
-    @classmethod
-    def setUpClass(self):
-        targetdir = os.path.join(self.tc.sdk_dir, "guessing-game")
-        try:
-            shutil.rmtree(targetdir)
-        except FileNotFoundError:
-            pass
-        shutil.copytree(
-            os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir
-        )
-
     def setUp(self):
         machine = self.td.get("MACHINE")
         self.ensure_host_package("python3-maturin")
@@ -58,9 +47,17 @@  class MaturinDevelopTest(OESDKTestCase):
           (1) that a .venv can been created.
           (2) a functional 'rustc' and 'cargo'
         """
-        self._run("cd %s/guessing-game; python3 -m venv .venv" % self.tc.sdk_dir)
-        cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir
-        output = self._run(cmd)
+        targetdir = os.path.join(self.tc.sdk_dir, "guessing-game")
+        try:
+            shutil.rmtree(targetdir)
+        except FileNotFoundError:
+            pass
+        shutil.copytree(
+            os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir
+        )
+
+        self._run("cd %s; python3 -m venv .venv" % targetdir)
+        output = self._run("cd %s; maturin develop" % targetdir)
         self.assertRegex(output, r"