-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
Dropped coverage on Django 1.11 #524
Comments
cc @vdboor |
Is the last bit a red herring, perhaps? It looks like they used to hardcode the class names but this was fixed in the following commit: django/django@48826aa#diff-5b0dda5eb9a242c15879dc9cd2121379 ... which is no help at all, I know. But if true, at least we know it's not because the QuerySet class is different! This is a frustrating one. |
Do you use v1.2 of polymorphic that officially supports django 1.11? |
It seems that they adapted the code following a change in django 1.11, related to the queryset iteration: jazzband/django-polymorphic@dbad7bd (not sure if really related, though! I was looking for important changes in this release) |
@jleclanche: Looking at this from a different angle - In the It doesn't throw the exception in Django 1.11, which is why we get the code coverage drop. So let's examine some of the possibilities:
The former is good, and we can put this down as innocuous, and maybe remove the try/except because Django 1.11 is superior (etc.). The latter is bad, and we'll need to figure out if it's something that we can fix, or that we can fix upstream within either Noticed that @twidi jumped in here to mention the upgrade use the newer style iteration. Yep, noticed that too. It's possible that executing Need to do a couple of things to confirm further:
|
@lskillen Unless I misunderstand you, it's not a refetch, it's a prefetch of the related objects. In Django 1.11, the prefetch succeeds (into a PolymorphicQuerySet) whereas on Django 1.10, it fails. I haven't looked at what changed in polymorphic itself because I used the same version for both 1.10 and 1.11 (the latest one, 1.2). |
Confirmed on the red herring at least (this is Django 1.10):
As for the refetch, said this on gitter:
|
Wee! We figured it out together on Gitter.
That means that this if type(...) check falls through. Signs point to the if check having to be replaced with the following: if issubclass(type(orig_accessor), (ReverseOneToOneDescriptor, ForwardManyToOneDescriptor])): I will submit a pull request to django-polymorphic. |
@jleclanche and I did a bit of sleuthing this morning, and it's due to
The proposal is to change the type check to a subclass check instead as
What we're not certain about is:
|
PR submitted: jazzband/django-polymorphic#291 |
I'm closing this, it's in the hands of polymorphic now. |
Tracking issue for Django 1.11 dropped coverage.
On Django 1.11, coverage has dropped in one very specific place:
Card.remove()
:In the following method, the final
except
is never raised. Now, this is supposedly harmless, but we want to understand why before we greenlight Django 1.11.This try/except was added by yours truly in commit 942ced2. That commit added the following test which forces the DoesNotExist to trigger:
This test can be reduced to the following, which fails on Django 1.10 and passes on Django 1.11:
And here is the traceback:
Now, it's worth noting that raising DoesNotExist on a delete() is not normal behaviour. Easy enough to test with a random django model:
Indeed we see in the traceback that the DoesNotExist is raised not in the delete itself, but in the collector that gathers related models before performing the delete.
The Model.delete method in Django has not changed since 1.10, and for that matter neither has the Collector.delete method. The error happens in that last method in the list comprehension
parent_objs = [getattr(obj, ptr.name) for obj in new_objs]
. This accesses thename
attribute, which is created as a property on lines 161 and 179 of polymorphic/models.py.This jumps into django/db/models/manager.py which hasn't changed since 1.10 either. And finally ends in the get() method of query.py which... hasn't changed either.
Some debugging lets me see the values of self, clone, args and kwargs. Django 1.10:
Django 1.11:
Okay, so on Django 1.10 it's called three times, and once it gets to the last call it errors out. On Django 1.11 it's only called once, because
self
is not a QuerySet but a PolymorphicQuerySet.Digging further, this confusion happens in PolymorphicManager.get_queryset(). Both in Django 1.10 and Django 1.11,
self.queryset_class
isPolymorphicQuerySet
, and yet, the following line returns different things:Phew, okay, so we can reduce the failure to the following:
Well, this is where I'm stumped. None of django's
manager.py
changed in 1.10->1.11. And yet, this changed. Any ideas?The text was updated successfully, but these errors were encountered: