Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ matrix:
- { stage: build_and_package_sanity, python: 3.6, env: SANITY_CHECK=1 }

before_install:
- git clone --depth 1 https://github.com/PyCQA/pylint.git ~/pylint
- git clone --depth 1 https://github.com/PyCQA/pylint.git --branch 2.4 --single-branch ~/pylint

install:
- pip install tox-travis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Book(models.Model):
author = models.ForeignKey(to='input.Author', on_delete=models.CASCADE)
author = models.ForeignKey(to='pylint_django.tests.input.Author', on_delete=models.CASCADE)

def get_author_name(self):
return self.author.id
32 changes: 22 additions & 10 deletions pylint_django/tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@

import pylint

if pylint.__version__ >= '2.4':
# after version 2.4 pylint stopped shipping the test directory
# as part of the package so we check it out locally for testing
sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests'))
else:
# because there's no __init__ file in pylint/test/
sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test'))

import test_functional # noqa: E402
try:
# pylint 2.5: test_functional has been moved to pylint.testutils
from pylint.testutils import FunctionalTestFile, LintModuleTest
except (ImportError, AttributeError):
# specify directly the directory containing test_functional.py
test_functional_dir = os.getenv('PYLINT_TEST_FUNCTIONAL_DIR', '')

# otherwise look for in in ~/pylint/tests - pylint 2.4
# this is the pylint git checkout dir, not the pylint module dir
if not os.path.isdir(test_functional_dir):
test_functional_dir = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')

# or site-packages/pylint/test/ - pylint before 2.4
if not os.path.isdir(test_functional_dir):
test_functional_dir = os.path.join(os.path.dirname(pylint.__file__), 'test')

sys.path.append(test_functional_dir)

from test_functional import FunctionalTestFile, LintModuleTest


# alter sys.path again because the tests now live as a subdirectory
# of pylint_django
Expand All @@ -22,7 +34,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), 'input'))


class PylintDjangoLintModuleTest(test_functional.LintModuleTest):
class PylintDjangoLintModuleTest(LintModuleTest):
"""
Only used so that we can load this plugin into the linter!
"""
Expand Down Expand Up @@ -53,7 +65,7 @@ def _file_name(test):
suite = []
for fname in os.listdir(input_dir):
if fname != '__init__.py' and fname.endswith('.py'):
suite.append(test_functional.FunctionalTestFile(input_dir, fname))
suite.append(FunctionalTestFile(input_dir, fname))

# when testing the db_performance plugin we need to sort by input file name
# because the plugin reports the errors in close() which appends them to the
Expand Down