mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-09 05:24:53 +08:00
latest changes
This commit is contained in:
28
test/pytest_tests/test_objects_queryset.py
Normal file
28
test/pytest_tests/test_objects_queryset.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from test.pytest_plugin import reveal_type, output
|
||||
from test.pytest_tests.base import BaseDjangoPluginTestCase
|
||||
|
||||
|
||||
class TestObjectsQueryset(BaseDjangoPluginTestCase):
|
||||
def test_every_model_has_objects_queryset_available(self):
|
||||
from django.db import models
|
||||
|
||||
class User(models.Model):
|
||||
pass
|
||||
|
||||
reveal_type(User.objects) # E: Revealed type is 'django.db.models.query.QuerySet[main.User]'
|
||||
|
||||
@output("""
|
||||
main:10: error: Revealed type is 'Any'
|
||||
main:10: error: "Type[ModelMixin]" has no attribute "objects"
|
||||
""")
|
||||
def test_objects_get_returns_model_instance(self):
|
||||
from django.db import models
|
||||
|
||||
class ModelMixin(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class User(ModelMixin):
|
||||
pass
|
||||
|
||||
reveal_type(User.objects.get()) # E: Revealed type is 'main.User*'
|
||||
Reference in New Issue
Block a user