From 6a921b04d5cf8a9e70dc6286832acfc72d40287b Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Thu, 22 Aug 2024 08:31:57 +0200 Subject: [PATCH] try fixing test --- tests/db/models/test_base.py | 22 +++++++++++++--------- tests/testapp/models.py | 2 -- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/db/models/test_base.py b/tests/db/models/test_base.py index 278c82c..03f2158 100644 --- a/tests/db/models/test_base.py +++ b/tests/db/models/test_base.py @@ -273,15 +273,19 @@ def test_check_sf_object_name_concrete(self): # invalid when just definiting `Meta.app_label`. # So for this test we just use an existing model and break # it. - setattr(NumberModel, "sf_object_name", None) - - errors = NumberModel.check() - assert errors == [ - checks.Error( - 'testapp.NumberModel must define a "sf_object_name".', - id="heroku_connect.E001", - ) - ] + old_name = NumberModel.sf_object_name + try: + setattr(NumberModel, "sf_object_name", None) + + errors = NumberModel.check() + assert errors == [ + checks.Error( + 'testapp.NumberModel must define a "sf_object_name".', + id="heroku_connect.E001", + ) + ] + finally: + setattr(NumberModel, "sf_object_name", old_name) def test_check_sf_access(self): class MyModel(hc_models.HerokuConnectModel): diff --git a/tests/testapp/models.py b/tests/testapp/models.py index fe79de5..d15ddb1 100644 --- a/tests/testapp/models.py +++ b/tests/testapp/models.py @@ -5,8 +5,6 @@ from heroku_connect.db import models as hc_models -__all__ = ("NumberModel", "OtherModel") - def frozen_uuid_generator(): return uuid.UUID(hex="653d1c6863404b9689b75fa930c9d0a0")