Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove catching of AttributeError in DescriptorWrapper #624

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading