Skip to content

Commit

Permalink
Merge pull request #624 from ProtixIT/DescriptorWrapper-no-catch
Browse files Browse the repository at this point in the history
Remove catching of `AttributeError` in `DescriptorWrapper`
  • Loading branch information
foarsitter authored Jun 13, 2024
2 parents 4275f84 + 14cf1b0 commit e35c724
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions model_utils/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ def __get__(self, instance, owner):
if instance is None:
return self
was_deferred = self.field_name in instance.get_deferred_fields()
try:
value = self.descriptor.__get__(instance, owner)
except AttributeError:
value = self.descriptor
value = self.descriptor.__get__(instance, owner)
if was_deferred:
tracker_instance = getattr(instance, self.tracker_attname)
tracker_instance.saved_data[self.field_name] = lightweight_deepcopy(value)
Expand Down
2 changes: 1 addition & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class TrackedAbstract(AbstractTracked):
number = models.IntegerField()
mutable = MutableField(default=None)

tracker = FieldTracker()
tracker = ModelTracker()


class TrackedNotDefault(models.Model):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_fields/test_field_tracker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from unittest import skip

from django.core.cache import cache
from django.core.exceptions import FieldError
from django.db import models
Expand Down Expand Up @@ -877,7 +875,6 @@ def test_child_fields_not_tracked(self):
self.assertTrue(self.tracker.has_changed('name2'))


@skip("has known failures")
class AbstractModelTrackerTests(ModelTrackerTests):

tracked_class = TrackedAbstract
Expand Down

0 comments on commit e35c724

Please sign in to comment.