From b9d57aa710d2695c107c6ae69c37b97f761d2da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Sun, 1 Mar 2026 09:16:02 +0100 Subject: [PATCH] [FIX] odoo_repository: fix tests cleanup and remove unused code Following up 6000479e0ea54398f13cb3909b9516859802d886 --- odoo_repository/tests/common.py | 14 +++++++++++++- odoo_repository/tests/odoo_repo_mixin.py | 18 +----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/odoo_repository/tests/common.py b/odoo_repository/tests/common.py index 1dc34b3..5b388f3 100644 --- a/odoo_repository/tests/common.py +++ b/odoo_repository/tests/common.py @@ -4,6 +4,7 @@ import pathlib import re +import shutil import tempfile from unittest.mock import patch @@ -24,7 +25,7 @@ def setUpClass(cls): "odoo_repository_storage_path", cls.repositories_path ) # org and repository - cls.repo_name = pathlib.Path(cls.repo_upstream_path).parts[-1] + cls.repo_name = cls.repo_upstream_path.parts[-1] cls.org = cls.env["odoo.repository.org"].create({"name": cls.fork_org}) cls.odoo_repository = cls.env["odoo.repository"].create( { @@ -149,3 +150,14 @@ def _create_odoo_module_branch(cls, module, branch, **values): } vals.update(values) return cls.env["odoo.module.branch"].create(vals) + + @classmethod + def tearDownClass(cls): + super().tearDownClass() + shutil.rmtree(cls.repositories_path) + + def tearDown(self): + super().tearDown() + repositories_path = pathlib.Path(self.repositories_path) + for sub_path in repositories_path.iterdir(): + shutil.rmtree(sub_path) diff --git a/odoo_repository/tests/odoo_repo_mixin.py b/odoo_repository/tests/odoo_repo_mixin.py index 40cee15..3fad199 100644 --- a/odoo_repository/tests/odoo_repo_mixin.py +++ b/odoo_repository/tests/odoo_repo_mixin.py @@ -35,9 +35,6 @@ def setUpClass(cls): cls.repo_upstream_path = cls._get_upstream_repository_path() cls.addon_path = Path(cls.repo_upstream_path) / cls.addon cls.manifest_path = cls.addon_path / "__manifest__.py" - # By cloning the first repository this will set an 'origin' remote - cls.repo_path = cls._clone_tmp_git_repository(cls.repo_upstream_path) - cls._add_fork_remote(cls.repo_path) @classmethod def _apply_git_config(cls): @@ -101,12 +98,6 @@ def _create_tmp_git_repository(cls) -> Path: git.Repo.init(repo_path) return Path(repo_path) - @classmethod - def _clone_tmp_git_repository(cls, upstream_path: Path) -> Path: - repo_path = tempfile.mkdtemp() - git.Repo.clone_from(upstream_path, repo_path) - return Path(repo_path) - @classmethod def _fill_git_repository(cls, repo_path: Path, addon_path: Path): """Create branches with some content in the Git repository.""" @@ -163,15 +154,8 @@ def _create_module(cls, module_path: Path): with open(manifest_path, "w") as manifest: manifest.writelines(manifest_lines) - @classmethod - def _add_fork_remote(cls, repo_path: Path): - repo = git.Repo(repo_path) - # We do not really care about the remote URL here, re-use origin one - repo.create_remote(cls.fork_org, repo.remotes.origin.url) - @classmethod def tearDownClass(cls): super().tearDownClass() - # Clean up the Git repository + # Clean up upstream Git repository shutil.rmtree(cls.repo_upstream_path) - shutil.rmtree(cls.repo_path)