Skip to content

Commit b8ec891

Browse files
imomalievatodorov
authored andcommitted
failing tests for FK as string from models as package
1 parent ad14b6e commit b8ec891

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .author import Author
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# pylint: disable=missing-docstring,wrong-import-position
2+
from django.db import models
3+
4+
5+
class Author(models.Model):
6+
pass
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Checks that Pylint does not complain about ForeignKey pointing to model
3+
in module of models package
4+
"""
5+
# pylint: disable=missing-docstring,wrong-import-position
6+
from django.db import models
7+
from django.db.models import ForeignKey
8+
9+
10+
class FairyTail(models.Model):
11+
# this fails key_cls UnboundLocalError: local variable 'key_cls' referenced before assignment
12+
author = models.ForeignKey(to='input.Author', null=True, on_delete=models.CASCADE)
13+
14+
def get_author_name(self):
15+
return self.author.id
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Checks that Pylint does not complain about ForeignKey pointing to model
3+
in module of models package
4+
"""
5+
# pylint: disable=missing-docstring,wrong-import-position
6+
from django.db import models
7+
from django.db.models import ForeignKey
8+
9+
10+
class Book(models.Model):
11+
author = models.ForeignKey(to='input.Author', on_delete=models.CASCADE)
12+
13+
def get_author_name(self):
14+
return self.author.id

pylint_django/tests/test_func.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def _file_name(test):
5656

5757

5858
TESTS = get_tests()
59+
TESTS.extend(get_tests('input/models'))
5960
TESTS_NAMES = [t.base for t in TESTS]
6061

6162

0 commit comments

Comments
 (0)