paulocheque / django-dynamic-fixture

A complete library to create dynamic model instances for testing purposes.
http://django-dynamic-fixture.readthedocs.io/
Other
390 stars 67 forks source link

Don't swallow exceptions when saving polymorphic models. #61

Closed mrmachine closed 4 years ago

mrmachine commented 9 years ago

If an exception is raised in the save() method of a polymorphic model, DDF tries to print all the field values for the model which will in turn raise a DoesNotExist exception on the *_ptr field, that masks the real exception.

This commit catches and displays the repr() of exceptions raised in when displaying field values in the print_field_values_of_a_model() method, which allows the real exception to exposed via BadDataError.

It might be more appropriate to just not display field values for *_ptr fields, though, as they are not set directly by the user.

landscape-bot commented 9 years ago

Code Health Repository health increased by 2% when pulling 178046f on ixc:cannot-save-polymorphic into f5f7207 on paulocheque:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.33%) to 79.54% when pulling 178046f7e6cbbbea97a31f60988bbd1df8bc15e9 on ixc:cannot-save-polymorphic into f5f72077eef6fcdc2113e332561fe5118aa4c85f on paulocheque:master.

landscape-bot commented 9 years ago

Code Health Code quality remained the same when pulling 365b99b on ixc:cannot-save-polymorphic into 3cffded on paulocheque:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.2%) to 76.68% when pulling 365b99b446476c1f893547d2b6088c87d7b16189 on ixc:cannot-save-polymorphic into 3cffded3740e7cc811bfa4c27677c38dba042732 on paulocheque:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.2%) to 76.68% when pulling 365b99b446476c1f893547d2b6088c87d7b16189 on ixc:cannot-save-polymorphic into 3cffded3740e7cc811bfa4c27677c38dba042732 on paulocheque:master.

mrmachine commented 9 years ago

@paulocheque any feedback on this issue?

paulocheque commented 9 years ago

@mrmachine The like the try/exceptcode. I would like to merge this code without the extra code. Check my comments in the #59 issue

paulocheque commented 4 years ago

Closing in favor of https://github.com/paulocheque/django-dynamic-fixture/pull/112