mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 12:44:29 +08:00
29 lines
864 B
Python
29 lines
864 B
Python
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*'
|