forked from carltongibson/django-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve exception message for invalid filter result (carltongibson#943)
* Improve exception message for invalid filter calls The current exception is an AttributeError that lacks any context about the filter call. e.g., "NoneType has no attribute filter". This message is improved by including which filterset and which filter are incorrect. * Fix tests broken by new exception
- Loading branch information
1 parent
f81af87
commit 82a47fb
Showing
4 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from unittest import mock | ||
|
||
from django.db import models | ||
|
||
|
||
class MockQuerySet: | ||
""" | ||
Generate a mock that is suitably similar to a QuerySet | ||
""" | ||
|
||
def __new__(self): | ||
m = mock.Mock(spec_set=models.QuerySet()) | ||
m.filter.return_value = m | ||
m.all.return_value = m | ||
return m |