mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-27 22:31:13 +08:00
add clean django-stubs folder, add some tests
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
[case testBasicCheck]
|
||||
from typing import Any
|
||||
|
||||
class A:
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
pass
|
||||
[out]
|
||||
12
test/test-data/check-model-fields.test
Normal file
12
test/test-data/check-model-fields.test
Normal file
@@ -0,0 +1,12 @@
|
||||
[case testBasicModelFields]
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
user = User()
|
||||
reveal_type(user.id) # E: Revealed type is 'builtins.int'
|
||||
reveal_type(user.name) # E: Revealed type is 'builtins.str'
|
||||
[out]
|
||||
13
test/test-data/check-postgres-fields.test
Normal file
13
test/test-data/check-postgres-fields.test
Normal file
@@ -0,0 +1,13 @@
|
||||
[case testArrayField]
|
||||
import typing
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
members = ArrayField(base_field=models.IntegerField())
|
||||
|
||||
user = User()
|
||||
reveal_type(user.members) # E: Revealed type is 'typing.List[int]'
|
||||
[out]
|
||||
@@ -13,6 +13,7 @@ TEST_DATA_DIR = ROOT_DIR / 'test' / 'test-data'
|
||||
|
||||
class DjangoTestSuite(DataSuite):
|
||||
files = [
|
||||
'check-model-fields.test',
|
||||
'check-postgres-fields.test'
|
||||
]
|
||||
data_prefix = str(TEST_DATA_DIR)
|
||||
|
||||
Reference in New Issue
Block a user