-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Deprecate the 'Meta.together' option * 'Filter.name' => 'Filter.field_name' * Add strictness migration note
- Loading branch information
1 parent
91002d5
commit 9a1c122
Showing
4 changed files
with
134 additions
and
28 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,54 @@ | ||
|
||
import warnings | ||
|
||
from django.test import TestCase | ||
|
||
from django_filters import FilterSet, filters | ||
|
||
|
||
class TogetherOptionDeprecationTests(TestCase): | ||
|
||
def test_deprecation(self): | ||
with warnings.catch_warnings(record=True) as w: | ||
warnings.simplefilter("always") | ||
|
||
class F(FilterSet): | ||
class Meta: | ||
together = ['a', 'b'] | ||
|
||
self.assertEqual(len(w), 1) | ||
self.assertTrue(issubclass(w[0].category, DeprecationWarning)) | ||
self.assertIn('The `Meta.together` option has been deprecated', str(w[0].message)) | ||
|
||
|
||
class FilterNameDeprecationTests(TestCase): | ||
|
||
def test_declaration(self): | ||
with warnings.catch_warnings(record=True) as w: | ||
warnings.simplefilter("always") | ||
|
||
class F(FilterSet): | ||
foo = filters.CharFilter(name='foo') | ||
|
||
self.assertEqual(len(w), 1) | ||
self.assertTrue(issubclass(w[0].category, DeprecationWarning)) | ||
self.assertIn("`Filter.name` has been renamed to `Filter.field_name`.", str(w[0].message)) | ||
|
||
def test_name_property(self): | ||
with warnings.catch_warnings(record=True) as w: | ||
warnings.simplefilter("always") | ||
|
||
filters.CharFilter().name | ||
|
||
self.assertEqual(len(w), 1) | ||
self.assertTrue(issubclass(w[0].category, DeprecationWarning)) | ||
self.assertIn("`Filter.name` has been renamed to `Filter.field_name`.", str(w[0].message)) | ||
|
||
with warnings.catch_warnings(record=True) as w: | ||
warnings.simplefilter("always") | ||
|
||
filters.CharFilter().name = 'bar' | ||
|
||
self.assertEqual(len(w), 1) | ||
self.assertTrue(issubclass(w[0].category, DeprecationWarning)) | ||
self.assertIn("`Filter.name` has been renamed to `Filter.field_name`.", str(w[0].message)) |