Merge pull request #3861 from linovia/feature/relation_get_queryset_override

Refactor the `get_queryset` overriding test
This commit is contained in:
Xavier Ordoquy 2016-01-21 18:10:32 +01:00
commit 909a3e80a1

View File

@ -176,10 +176,12 @@ class TestSlugRelatedField(APISimpleTestCase):
representation = self.field.to_representation(self.instance)
assert representation == self.instance.name
def test_no_queryset_init(self):
def test_overriding_get_queryset(self):
qs = self.queryset
class NoQuerySetSlugRelatedField(serializers.SlugRelatedField):
def get_queryset(this):
return self.queryset
def get_queryset(self):
return qs
field = NoQuerySetSlugRelatedField(slug_field='name')
field.to_internal_value(self.instance.name)