Skip to content

Commit 17d59fc

Browse files
imomalievatodorov
authored andcommitted
failing tests for FK as string with no app prefix
1 parent 266b234 commit 17d59fc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
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
6+
from django.db import models
7+
8+
9+
class FairyTail(models.Model):
10+
# fails with "UnboundLocalError: local variable 'key_cls' referenced before assignment"
11+
# when 'Author' model comes from same models package
12+
author = models.ForeignKey(to='Author', null=True, on_delete=models.CASCADE)
13+
14+
def get_author_name(self):
15+
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)