diff --git a/base_product_mass_addition/tests/test_product_mass_addition.py b/base_product_mass_addition/tests/test_product_mass_addition.py index 163245b0ead..68a7019235d 100644 --- a/base_product_mass_addition/tests/test_product_mass_addition.py +++ b/base_product_mass_addition/tests/test_product_mass_addition.py @@ -20,6 +20,7 @@ def setUpClass(cls): # Setup Fake Models cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() + cls.addClassCleanup(cls.loader.restore_registry) from .models.order import ModelOrder, ModelOrderLine cls.loader.update_registry( diff --git a/product_packaging_container_deposit/tests/test_container_deposit_order_mixin.py b/product_packaging_container_deposit/tests/test_container_deposit_order_mixin.py index 95a946742a4..5d6c34aee8b 100644 --- a/product_packaging_container_deposit/tests/test_container_deposit_order_mixin.py +++ b/product_packaging_container_deposit/tests/test_container_deposit_order_mixin.py @@ -15,6 +15,7 @@ def setUpClass(cls): super().setUpClass() cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() + cls.addClassCleanup(cls.loader.restore_registry) from .fake_models import ( ContainerDepositOrderLineTest, ContainerDepositOrderTest, diff --git a/product_secondary_unit/tests/test_secondary_unit_mixin.py b/product_secondary_unit/tests/test_secondary_unit_mixin.py index e0ff1b4dcdd..79e79ab8439 100644 --- a/product_secondary_unit/tests/test_secondary_unit_mixin.py +++ b/product_secondary_unit/tests/test_secondary_unit_mixin.py @@ -11,6 +11,7 @@ def setUpClass(cls): super().setUpClass() cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() + cls.addClassCleanup(cls.loader.restore_registry) from .models import SecondaryUnitFake cls.loader.update_registry((SecondaryUnitFake,)) @@ -57,11 +58,6 @@ def setUpClass(cls): } ) - @classmethod - def tearDownClass(cls): - cls.loader.restore_registry() - return super(TestProductSecondaryUnitMixin, cls).tearDownClass() - def test_product_secondary_unit_mixin(self): fake_model = self.secondary_unit_fake diff --git a/product_set/tests/test_product_set_wizard.py b/product_set/tests/test_product_set_wizard.py index 74d9be5f1e3..b2491220573 100644 --- a/product_set/tests/test_product_set_wizard.py +++ b/product_set/tests/test_product_set_wizard.py @@ -12,6 +12,7 @@ def setUpClass(cls): super().setUpClass() cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() + cls.addClassCleanup(cls.loader.restore_registry) from .models import FakeProductSetWizard cls.loader.update_registry((FakeProductSetWizard,)) @@ -26,11 +27,6 @@ def setUpClass(cls): } ) - @classmethod - def tearDownClass(cls): - cls.loader.restore_registry() - return super().tearDownClass() - def test_product_set_wizard_compute_lines(self): # Check if the wizard lines are updated when the product set changes self.assertTrue(self.wizard.product_set_id, self.product_set_1)