Skip to content

Commit 7ceef1f

Browse files
committed
Add tests for the new fields
1 parent 08bf566 commit 7ceef1f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/typecheck/fields.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ reveal_type(user.name) # E: Revealed type is 'builtins.str'
3737
reveal_type(user.slug) # E: Revealed type is 'builtins.str'
3838
reveal_type(user.text) # E: Revealed type is 'builtins.str'
3939

40+
[CASE test_model_field_classes_from_exciting_locations]
41+
from django.db import models
42+
from django.contrib.postgres import fields as pg_fields
43+
from psycopg2.extras import DateTimeTZRange
44+
from decimal import Decimal
45+
46+
class Booking(models.Model):
47+
id = models.AutoField(primary_key=True)
48+
time_range = pg_fields.DateTimeRangeField(null=False)
49+
some_decimal = models.DecimalField(max_digits=10, decimal_places=5)
50+
51+
booking = Booking()
52+
reveal_type(user.id) # E: Revealed type is 'builtins.int'
53+
reveal_type(booking.time_range) # E: Revealed type is 'DateTimeTZRange'
54+
reveal_type(booking.some_decimal) # E: Revealed type is 'Decimal'
55+
4056
[CASE test_add_id_field_if_no_primary_key_defined]
4157
from django.db import models
4258

0 commit comments

Comments
 (0)