From 6c87ccf2281f6a1b2d26500347bb059af3528016 Mon Sep 17 00:00:00 2001 From: Aleksander Vognild Burkow Date: Mon, 4 Feb 2019 17:02:23 +0100 Subject: [PATCH] Add tests for the new fields --- test-data/typecheck/fields.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test-data/typecheck/fields.test b/test-data/typecheck/fields.test index 96c0e9b..46977d7 100644 --- a/test-data/typecheck/fields.test +++ b/test-data/typecheck/fields.test @@ -37,6 +37,22 @@ reveal_type(user.name) # E: Revealed type is 'builtins.str' reveal_type(user.slug) # E: Revealed type is 'builtins.str' reveal_type(user.text) # E: Revealed type is 'builtins.str' +[CASE test_model_field_classes_from_exciting_locations] +from django.db import models +from django.contrib.postgres import fields as pg_fields +from psycopg2.extras import DateTimeTZRange +from decimal import Decimal + +class Booking(models.Model): + id = models.AutoField(primary_key=True) + time_range = pg_fields.DateTimeRangeField(null=False) + some_decimal = models.DecimalField(max_digits=10, decimal_places=5) + +booking = Booking() +reveal_type(booking.id) # E: Revealed type is 'builtins.int' +reveal_type(booking.time_range) # E: Revealed type is 'DateTimeTZRange' +reveal_type(booking.some_decimal) # E: Revealed type is 'Decimal' + [CASE test_add_id_field_if_no_primary_key_defined] from django.db import models