Skip to content

Commit

Permalink
[FIX]: Use cls.addClassCleanup(cls.loader.restore_registry)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaule97 committed Nov 13, 2024
1 parent 28db8a2 commit 5baf68a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions product_secondary_unit/tests/test_secondary_unit_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions product_set/tests/test_product_set_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand All @@ -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)
Expand Down

0 comments on commit 5baf68a

Please sign in to comment.