Skip to content

Commit e1d268f

Browse files
ngtvspcatodorov
authored andcommitted
Add test specifically for the filter() method returning a list
Add a test case for the basic case that a call to a Manager or QuerySets filter() method returns another QuerySet.
1 parent 6d151d8 commit e1d268f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
Checks that Pylint does not complain about Manager methods returning lists
3+
when they in fact return QuerySets
4+
"""
5+
6+
from django.db import models
7+
8+
9+
class SomeModelQuerySet(models.QuerySet):
10+
""" A missing docstring """
11+
@staticmethod
12+
def public_method():
13+
""" A missing docstring """
14+
return 1
15+
16+
17+
class SomeModelManager(models.Manager):
18+
"""A missing docstring"""
19+
20+
@staticmethod
21+
def public_method():
22+
""" A missing docstring """
23+
return 1
24+
25+
@staticmethod
26+
def another_public_method():
27+
""" A missing docstring """
28+
return 1
29+
30+
31+
class SomeModel(models.Model):
32+
""" A missing docstring """
33+
34+
name = models.CharField(max_length=20)
35+
datetimestamp = models.DateTimeField()
36+
37+
objects = SomeModelManager()
38+
39+
40+
class OtherModel(models.Model):
41+
""" A missing docstring """
42+
43+
name = models.CharField(max_length=20)
44+
somemodel = models.ForeignKey(SomeModel, on_delete=models.CASCADE, null=False)
45+
46+
47+
def call_some_querysets():
48+
""" A missing docstring """
49+
50+
not_a_list = SomeModel.objects.filter()
51+
not_a_list.values_list('id', flat=True)

0 commit comments

Comments
 (0)