From cf7c263fb52f0bc04ef2f5f9cfcc6b925c04f499 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Tue, 12 Feb 2019 17:09:28 +0300 Subject: [PATCH] fix tests --- scripts/typecheck_tests.py | 4 ---- test-data/typecheck/model_create.test | 2 +- test-data/typecheck/model_init.test | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index d5ca59c..197157d 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -500,16 +500,12 @@ TESTS_DIRS = [ 'update', 'update_only_fields', 'urlpatterns', - # not annotatable without annotation in test # TODO: 'urlpatterns_reverse', - 'user_commands', # TODO: 'utils_tests', - # not annotatable without annotation in test # TODO: 'validation', - 'validators', 'version', 'view_tests', diff --git a/test-data/typecheck/model_create.test b/test-data/typecheck/model_create.test index 3a15fa2..cc6f9ee 100644 --- a/test-data/typecheck/model_create.test +++ b/test-data/typecheck/model_create.test @@ -6,7 +6,7 @@ class User(models.Model): age = models.IntegerField() User.objects.create(name='Max', age=10) -User.objects.create(name=1010) # E: Incompatible type for "name" of "User" (got "int", expected "Union[str, Combinable]") +User.objects.create(age='hello') # E: Incompatible type for "age" of "User" (got "str", expected "Union[int, Combinable, Literal['']]") [out] [CASE model_recognises_parent_attributes] diff --git a/test-data/typecheck/model_init.test b/test-data/typecheck/model_init.test index 29b2527..4f280d8 100644 --- a/test-data/typecheck/model_init.test +++ b/test-data/typecheck/model_init.test @@ -14,9 +14,9 @@ from django.db import models class MyUser(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() -user = MyUser(name=1, age=12) +user = MyUser(name='hello', age='world') [out] -main:6: error: Incompatible type for "name" of "MyUser" (got "int", expected "Union[str, Combinable]") +main:6: error: Incompatible type for "age" of "MyUser" (got "str", expected "Union[int, Combinable, Literal['']]") [CASE arguments_to_init_combined_from_base_classes] from django.db import models @@ -62,8 +62,8 @@ user3= MyUser2(pk=1) from django.db import models class MyUser1(models.Model): - mypk = models.CharField(primary_key=True) -user = MyUser1(pk=1) # E: Incompatible type for "pk" of "MyUser1" (got "int", expected "Union[str, Combinable]") + mypk = models.IntegerField(primary_key=True) +user = MyUser1(pk='hello') # E: Incompatible type for "pk" of "MyUser1" (got "str", expected "Union[int, Combinable, Literal['']]") [out] [CASE can_set_foreign_key_by_its_primary_key] @@ -72,13 +72,13 @@ from django.db import models class Publisher(models.Model): pass class PublisherWithCharPK(models.Model): - id = models.CharField(max_length=100, primary_key=True) + id = models.IntegerField(primary_key=True) class Book(models.Model): publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE) publisher_with_char_pk = models.ForeignKey(PublisherWithCharPK, on_delete=models.CASCADE) -Book(publisher_id=1, publisher_with_char_pk_id='hello') -Book(publisher_id=1, publisher_with_char_pk_id=1) # E: Incompatible type for "publisher_with_char_pk_id" of "Book" (got "int", expected "Union[str, Combinable]") +Book(publisher_id=1, publisher_with_char_pk_id=1) +Book(publisher_id=1, publisher_with_char_pk_id='hello') # E: Incompatible type for "publisher_with_char_pk_id" of "Book" (got "str", expected "Union[int, Combinable, Literal['']]") [out] [CASE setting_value_to_an_array_of_ints] @@ -112,9 +112,9 @@ class MyModel(models.Model): MyModel(1) class MyModel2(models.Model): - name = models.CharField(max_length=100) -MyModel2(1, 'Maxim') -MyModel2(1, 12) # E: Incompatible type for "name" of "MyModel2" (got "int", expected "Union[str, Combinable]") + name = models.IntegerField() +MyModel2(1, 12) +MyModel2(1, 'Maxim') # E: Incompatible type for "name" of "MyModel2" (got "str", expected "Union[int, Combinable, Literal['']]") [out] [CASE arguments_passed_as_dictionary_unpacking_are_not_supported]