Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e7a617d
Do not rely on the version number to know if the tests are present
aerostitch Nov 24, 2019
c03d78a
Add the ability to overwrite the pylint tests path using an environme…
aerostitch Nov 24, 2019
5126c5e
test_functional has been moved to pylint.testutils in pylint 2.5
aerostitch Nov 25, 2019
dbc50cb
Fix typo
aerostitch Nov 25, 2019
cc174d0
testutils existed before they moved the functional tests to it so got…
aerostitch Nov 25, 2019
bffd5a3
Trying the imports in another way
aerostitch Nov 25, 2019
23718e9
Checking for AttributeError instead of ImportError
aerostitch Nov 25, 2019
d131a0c
Try to avoid loading different version of the package if possible
aerostitch Nov 25, 2019
46bd41e
Handle different error types
aerostitch Nov 25, 2019
1624261
Use ImportError as ModuleNotFoundError is not always available
aerostitch Nov 25, 2019
cfe107c
Cloning the master sometimes leads to test_functional not being in sy…
aerostitch Nov 25, 2019
1bd7964
Make sure that the cloned dir is using pylint 2.4 as it is only there…
aerostitch Nov 25, 2019
0bff40c
Adding a debug message to make sure we are taking the right path with…
aerostitch Nov 25, 2019
5f9c2bf
Add comments and some debug to understand why it is still loading pyl…
aerostitch Nov 25, 2019
da2146c
Renaming the env to make sure there is no mismatch with the package name
aerostitch Nov 25, 2019
8656e0a
Do not pre-install the dependencies. Let tox take care of that.
aerostitch Nov 25, 2019
9694d2c
add coverage as global dep
aerostitch Nov 25, 2019
dc00577
Add the missing defaults from for_test
aerostitch Nov 25, 2019
1a12066
Add more missing dependencies
aerostitch Nov 25, 2019
703ed34
Missing dep again
aerostitch Nov 25, 2019
ff8e1e2
What is happening?
aerostitch Nov 25, 2019
fba1a56
Django_tables2 depends on django
aerostitch Nov 25, 2019
facd0b8
Remove debug messages
aerostitch Nov 25, 2019
1ef7453
Fix the module full path when using foreign key in tests
aerostitch Nov 25, 2019
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ matrix:
- { stage: test, python: 3.6, env: TOXENV=readme }
- { stage: build_and_package_sanity, python: 3.6, env: SANITY_CHECK=1 }

# This is a hack to go around missing test_functional in pip packages for pylint 2.4 and should be removed when relying
# on pylint >2.5 (along with a cleanup of pylint_django/tests/test_func.py)
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
- pip install -e .[for_tests]
script:
- |
if [ -z "$SANITY_CHECK" ]; then
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
50 changes: 39 additions & 11 deletions pylint_django/tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,43 @@

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
# PYLINT_TEST_FUNCTIONAL_PATH is can be used to force where to pull the classes used for functional testing
# Just make sure you use the exact same version as the one pylint version installed or just add that to PYTHONPATH
pylint_test_func_path = os.getenv('PYLINT_TEST_FUNCTIONAL_PATH', '')
if pylint_test_func_path != '':
sys.path.append(pylint_test_func_path)

# test_functional has been moved to pylint.testutils as part of the pytlint 2.5 release
# so we try first to load the basic cases and then look in more exotic places
try:
# pylint <= 2.4 case
# TODO: remove when the minimum supported version of pylint is 2.5.
from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402
except (ImportError, AttributeError):
try:
from pylint.testutils import FunctionalTestFile, LintModuleTest
except (ImportError, AttributeError):
# test in other more exotic directories
if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')):
# pre pylint 2.4, pylint was putting files in pylint/test
# TODO: remove when the minimum supported version of pylint is 2.4.
sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test'))
elif os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), '..', 'tests')):
# after version 2.4 pylint moved the test to a 'tests' folder at the root of the github tree
# to stopped shipping the tests along with the pip package
# but some distro re-add tests in the packages so only do that when not done at all
# TODO: remove when the minimum supported version of pylint is 2.5.
sys.path.append(os.path.join(os.path.dirname(pylint.__file__), '..', 'tests'))
else:
# This is a transitional hack specific to pylint 2.4 on travis and should be irrelevant anywhere else
# TODO: remove when the minimum supported version of pylint is 2.5.
sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests'))
try:
# TODO: remove when the minimum supported version of pylint is 2.5.
sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test'))
from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402
except (ImportError, AttributeError):
from pylint.testutils import FunctionalTestFile, LintModuleTest

# alter sys.path again because the tests now live as a subdirectory
# of pylint_django
Expand All @@ -22,7 +50,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 +81,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
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,30 @@ commands =
clean: find . -type d -name __pycache__ -delete
clean: rm -rf build/ .cache/ dist/ .eggs/ pylint_django.egg-info/ .tox/
deps =
coverage
factory-boy
pytest
django_is_installed: Django
django_is_installed: pylint-plugin-utils
django_is_installed: pylint
flake8: flake8
pylint: pylint
pylint: pylint-plugin-utils
pylint: Django
pylint: django_tables2
readme: twine
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<3.0
django{111,20,21,22}: pylint
django{111,20,21,22}: pylint-plugin-utils
django{111,20,21,22}: django_tables2
django-master: Django
django-master: django_tables2
django-master: git+https://github.com/pycqa/astroid@master
django-master: git+https://github.com/pycqa/pylint@master
django-master: git+https://github.com/PyCQA/pylint-plugin-utils@master
setenv =
PIP_DISABLE_PIP_VERSION_CHECK = 1
PYTHONPATH = .
Expand Down