From e7a617d0fcdfe4ff53b50b2e52178e82b6a4be5c Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 11:01:37 -0800 Subject: [PATCH 01/24] Do not rely on the version number to know if the tests are present --- pylint_django/tests/test_func.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 3b3cb5a2..9ab214ec 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,13 +5,14 @@ import pylint -if pylint.__version__ >= '2.4': +if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): + # because there's no __init__ file in pylint/test + sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) +else: # after version 2.4 pylint stopped shipping the test directory # as part of the package so we check it out locally for testing + # but some distro re-add tests in the packages so only do that when not done at all 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 From c03d78aca2686d09cfbd260def8c1a779b656e31 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 11:45:13 -0800 Subject: [PATCH 02/24] Add the ability to overwrite the pylint tests path using an environment variable --- pylint_django/tests/test_func.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 9ab214ec..994a0b50 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,14 +5,18 @@ import pylint -if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): - # because there's no __init__ file in pylint/test - sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) -else: - # after version 2.4 pylint stopped shipping the test directory - # as part of the package so we check it out locally for testing - # but some distro re-add tests in the packages so only do that when not done at all - sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) +# If PYLINT_TESTS_PATH is set it should be used to specify where to pull the tests from +pylint_tests_path = os.getenv('PYLINT_TESTS_PATH', '') +if pylint_tests_path == '': + if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): + # because there's no __init__ file in pylint/test + pylint_tests_path = os.path.join(os.path.dirname(pylint.__file__), 'test') + else: + # after version 2.4 pylint stopped shipping the test directory + # as part of the package so we check it out locally for testing + # but some distro re-add tests in the packages so only do that when not done at all + pylint_tests_path = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') +sys.path.append(pylint_tests_path) import test_functional # noqa: E402 From 5126c5ea6b508874f9da05c50bb22c0b8ac57330 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:14:05 -0800 Subject: [PATCH 03/24] test_functional has been moved to pylint.testutils in pylint 2.5 --- pylint_django/tests/test_func.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 994a0b50..048bf050 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,20 +5,25 @@ import pylint -# If PYLINT_TESTS_PATH is set it should be used to specify where to pull the tests from -pylint_tests_path = os.getenv('PYLINT_TESTS_PATH', '') -if pylint_tests_path == '': +# If PYLINT_TEST_FUNCTIONAL_PATH is set it should be used to specify where to pull the test_functional method from. +pylint_test_func_path = os.getenv('PYLINT_TEST_FUNCTIONAL_PATH', '') +if pylint_test_func_path == '': if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): # because there's no __init__ file in pylint/test - pylint_tests_path = os.path.join(os.path.dirname(pylint.__file__), 'test') + pylint_test_func_path = os.path.join(os.path.dirname(pylint.__file__), 'test') else: # after version 2.4 pylint stopped shipping the test directory # as part of the package so we check it out locally for testing # but some distro re-add tests in the packages so only do that when not done at all - pylint_tests_path = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') + pylint_test_func_path = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') sys.path.append(pylint_tests_path) -import test_functional # noqa: E402 +# test_functional has been moved to pylint.testutils as part of the pytlint 2.5 release +try: + import pylint.testutils as test_functional +except ImportError: + # pylint <= 2.4 case + import test_functional # noqa: E402 # alter sys.path again because the tests now live as a subdirectory # of pylint_django From dbc50cb9959b8121ff8a782b5f0799f067e2bd59 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:21:16 -0800 Subject: [PATCH 04/24] Fix typo --- pylint_django/tests/test_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 048bf050..c63c7649 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -16,11 +16,11 @@ # as part of the package so we check it out locally for testing # but some distro re-add tests in the packages so only do that when not done at all pylint_test_func_path = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') -sys.path.append(pylint_tests_path) +sys.path.append(pylint_test_func_path) # test_functional has been moved to pylint.testutils as part of the pytlint 2.5 release try: - import pylint.testutils as test_functional + from pylint import testutils as test_functional except ImportError: # pylint <= 2.4 case import test_functional # noqa: E402 From cc174d0faaff9e4c9eabb3b301946d7d8ad0ad76 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:26:26 -0800 Subject: [PATCH 05/24] testutils existed before they moved the functional tests to it so gotta do it the other way --- pylint_django/tests/test_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index c63c7649..a372a06e 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -20,10 +20,10 @@ # test_functional has been moved to pylint.testutils as part of the pytlint 2.5 release try: - from pylint import testutils as test_functional -except ImportError: # pylint <= 2.4 case import test_functional # noqa: E402 +except ImportError: + from pylint import testutils as test_functional # alter sys.path again because the tests now live as a subdirectory # of pylint_django From bffd5a31c08a04dab588d3e978c4ad39083f62ca Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:39:08 -0800 Subject: [PATCH 06/24] Trying the imports in another way --- pylint_django/tests/test_func.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index a372a06e..dae6436b 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -21,9 +21,9 @@ # test_functional has been moved to pylint.testutils as part of the pytlint 2.5 release try: # pylint <= 2.4 case - import test_functional # noqa: E402 + from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 except ImportError: - from pylint import testutils as test_functional + from pylint.testutils import FunctionalTestFile, LintModuleTest # alter sys.path again because the tests now live as a subdirectory # of pylint_django @@ -32,7 +32,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! """ @@ -63,7 +63,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 From 23718e98d74cc39b976c75e706203acd2daf84f6 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:44:29 -0800 Subject: [PATCH 07/24] Checking for AttributeError instead of ImportError --- pylint_django/tests/test_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index dae6436b..44f10cac 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,7 +5,7 @@ import pylint -# If PYLINT_TEST_FUNCTIONAL_PATH is set it should be used to specify where to pull the test_functional method from. +# PYLINT_TEST_FUNCTIONAL_PATH is can be used to force where to pull the classes used for functional testing pylint_test_func_path = os.getenv('PYLINT_TEST_FUNCTIONAL_PATH', '') if pylint_test_func_path == '': if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): @@ -22,7 +22,7 @@ try: # pylint <= 2.4 case from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 -except ImportError: +except AttributeError: from pylint.testutils import FunctionalTestFile, LintModuleTest # alter sys.path again because the tests now live as a subdirectory From d131a0ce0cfad7e6411a3ef8bd33b186cd5bf29b Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:48:33 -0800 Subject: [PATCH 08/24] Try to avoid loading different version of the package if possible --- pylint_django/tests/test_func.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 44f10cac..7731f2f8 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -7,23 +7,30 @@ # PYLINT_TEST_FUNCTIONAL_PATH is can be used to force where to pull the classes used for functional testing pylint_test_func_path = os.getenv('PYLINT_TEST_FUNCTIONAL_PATH', '') -if pylint_test_func_path == '': - if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): - # because there's no __init__ file in pylint/test - pylint_test_func_path = os.path.join(os.path.dirname(pylint.__file__), 'test') - else: - # after version 2.4 pylint stopped shipping the test directory - # as part of the package so we check it out locally for testing - # but some distro re-add tests in the packages so only do that when not done at all - pylint_test_func_path = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') -sys.path.append(pylint_test_func_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 from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 except AttributeError: - from pylint.testutils import FunctionalTestFile, LintModuleTest + try: + from pylint.testutils import FunctionalTestFile, LintModuleTest + except AttributeError: + if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): + # because there's no __init__ file in pylint/test + sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) + else: + # after version 2.4 pylint stopped shipping the test directory + # as part of the package so we check it out locally for testing + # but some distro re-add tests in the packages so only do that when not done at all + sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) + try: + from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 + except AttributeError: + from pylint.testutils import FunctionalTestFile, LintModuleTest # alter sys.path again because the tests now live as a subdirectory # of pylint_django From 46bd41e4aa5b154420ad1c5bb79f18713f656c9e Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 17:58:33 -0800 Subject: [PATCH 09/24] Handle different error types --- pylint_django/tests/test_func.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 7731f2f8..75455e68 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -15,10 +15,10 @@ try: # pylint <= 2.4 case from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 -except AttributeError: +except (ModuleNotFoundError, AttributeError): try: from pylint.testutils import FunctionalTestFile, LintModuleTest - except AttributeError: + except (ImportError, AttributeError): if os.path.isdir(os.path.join(os.path.dirname(pylint.__file__), 'test')): # because there's no __init__ file in pylint/test sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) @@ -26,10 +26,11 @@ # after version 2.4 pylint stopped shipping the test directory # as part of the package so we check it out locally for testing # but some distro re-add tests in the packages so only do that when not done at all + # Just make sure you use the exact same version as the one installed for the test files!!! sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) try: from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 - except AttributeError: + except (ModuleNotFoundError, AttributeError): from pylint.testutils import FunctionalTestFile, LintModuleTest # alter sys.path again because the tests now live as a subdirectory From 1624261b2276d1ab10f24f0f8b2507ae1ae0d314 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 18:04:54 -0800 Subject: [PATCH 10/24] Use ImportError as ModuleNotFoundError is not always available --- pylint_django/tests/test_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 75455e68..21efb30a 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -15,7 +15,7 @@ try: # pylint <= 2.4 case from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 -except (ModuleNotFoundError, AttributeError): +except (ImportError, AttributeError): try: from pylint.testutils import FunctionalTestFile, LintModuleTest except (ImportError, AttributeError): @@ -30,7 +30,7 @@ sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) try: from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 - except (ModuleNotFoundError, AttributeError): + except (ImportError, AttributeError): from pylint.testutils import FunctionalTestFile, LintModuleTest # alter sys.path again because the tests now live as a subdirectory From cfe107cc8a88a9b25d90d8551a4cfd23239b4de0 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 18:16:02 -0800 Subject: [PATCH 11/24] Cloning the master sometimes leads to test_functional not being in sync with the installed pkg --- .travis.yml | 3 --- pylint_django/tests/test_func.py | 13 +++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a51af805..25a4ae81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,6 @@ matrix: - { stage: test, python: 3.6, env: TOXENV=readme } - { 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 - install: - pip install tox-travis - pip install -e .[for_tests] diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 21efb30a..527921f3 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -6,6 +6,7 @@ import pylint # 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) @@ -19,15 +20,15 @@ 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')): - # because there's no __init__ file in pylint/test + # pre pylint 2.4, pylint was putting files in pylint/test sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) - else: - # after version 2.4 pylint stopped shipping the test directory - # as part of the package so we check it out locally for testing + 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 - # Just make sure you use the exact same version as the one installed for the test files!!! - sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) + sys.path.append(os.path.join(os.path.dirname(pylint.__file__), '..', 'tests')) try: from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 except (ImportError, AttributeError): From 1bd7964e28aaa7c2b49efc127b7384c0055bc4ac Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 18:28:41 -0800 Subject: [PATCH 12/24] Make sure that the cloned dir is using pylint 2.4 as it is only there to serve the transition --- .travis.yml | 2 ++ pylint_django/tests/test_func.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 25a4ae81..8dd55ee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ matrix: - { stage: test, python: 3.6, env: TOXENV=readme } - { stage: build_and_package_sanity, python: 3.6, env: SANITY_CHECK=1 } +before_install: + - 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] diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 527921f3..6c8892b2 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -29,6 +29,9 @@ # 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 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 + sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) try: from test_functional import FunctionalTestFile, LintModuleTest # noqa: E402 except (ImportError, AttributeError): From 0bff40c1f607d544ed2ff7a7e6c42c6d1d84191f Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 18:39:38 -0800 Subject: [PATCH 13/24] Adding a debug message to make sure we are taking the right path with pylint 2.5 --- pylint_django/tests/test_func.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 6c8892b2..701a7b25 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -20,6 +20,7 @@ try: from pylint.testutils import FunctionalTestFile, LintModuleTest except (ImportError, AttributeError): + print("DEBUG: This should not appear on pylint 2.5") # 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 @@ -30,6 +31,7 @@ # but some distro re-add tests in the packages so only do that when not done at all sys.path.append(os.path.join(os.path.dirname(pylint.__file__), '..', 'tests')) else: + print("DEBUG: we should not enter this condition with pylint 2.5") # This is a transitional hack specific to pylint 2.4 on travis and should be irrelevant anywhere else sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) try: From 5f9c2bff42601419207c5384c949de7d200bc526 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 18:57:37 -0800 Subject: [PATCH 14/24] Add comments and some debug to understand why it is still loading pylint 2.4 when it should not --- .travis.yml | 3 +++ pylint_django/tests/test_func.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8dd55ee8..a4b28921 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,11 @@ 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 --branch 2.4 --single-branch ~/pylint + install: - pip install tox-travis - pip install -e .[for_tests] diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index 701a7b25..ecd52cf2 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,6 +5,8 @@ import pylint +print('DEBUG: pylint version: {}'.format(pylint.__version__)) + # 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', '') @@ -15,26 +17,31 @@ # 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): - print("DEBUG: This should not appear on pylint 2.5") # 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: - print("DEBUG: we should not enter this condition with pylint 2.5") # 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: + print("DEBUG: we should not enter this condition with pylint 2.5") + # 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 From da2146cfbb3188cece154272a5b5059a4825bf39 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 19:29:08 -0800 Subject: [PATCH 15/24] Renaming the env to make sure there is no mismatch with the package name --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index fe9f40cf..c5ffeae8 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ envlist = django_not_installed django_is_installed flake8 - pylint + pylintpkg readme py{36}-django{111,20,-master} py{35,36,37}-django22 @@ -16,7 +16,7 @@ commands = django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py | grep django-not-available\' django_is_installed: pylint --load-plugins=pylint_django setup.py flake8: flake8 - pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup + pylintpkg: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup readme: bash -c \'python setup.py -q sdist && twine check dist/*\' py{36}-django{111,20,-master}: coverage run pylint_django/tests/test_func.py -v py{35,36,37}-django22: coverage run pylint_django/tests/test_func.py -v @@ -26,8 +26,8 @@ commands = deps = django_is_installed: Django flake8: flake8 - pylint: pylint - pylint: Django + pylintpkg: pylint + pylintpkg: Django readme: twine django111: Django>=1.11,<2.0 django20: Django>=2.0,<2.1 From 8656e0a5fab607ff6b716f8dfe2acedca58f6f81 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 19:32:05 -0800 Subject: [PATCH 16/24] Do not pre-install the dependencies. Let tox take care of that. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a4b28921..e939ab2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,6 @@ before_install: install: - pip install tox-travis - - pip install -e .[for_tests] script: - | if [ -z "$SANITY_CHECK" ]; then From 9694d2c614932df5193afccb9f52eb80d3800ec3 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 19:46:37 -0800 Subject: [PATCH 17/24] add coverage as global dep --- tox.ini | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index c5ffeae8..48e86eda 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ envlist = django_not_installed django_is_installed flake8 - pylintpkg + pylint readme py{36}-django{111,20,-master} py{35,36,37}-django22 @@ -16,7 +16,7 @@ commands = django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py | grep django-not-available\' django_is_installed: pylint --load-plugins=pylint_django setup.py flake8: flake8 - pylintpkg: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup + pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup readme: bash -c \'python setup.py -q sdist && twine check dist/*\' py{36}-django{111,20,-master}: coverage run pylint_django/tests/test_func.py -v py{35,36,37}-django22: coverage run pylint_django/tests/test_func.py -v @@ -24,10 +24,11 @@ commands = clean: find . -type d -name __pycache__ -delete clean: rm -rf build/ .cache/ dist/ .eggs/ pylint_django.egg-info/ .tox/ deps = + coverage django_is_installed: Django flake8: flake8 - pylintpkg: pylint - pylintpkg: Django + pylint: pylint + pylint: Django readme: twine django111: Django>=1.11,<2.0 django20: Django>=2.0,<2.1 From dc00577af3db95ff61eaab5264a6fb38c936ab9f Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 19:51:20 -0800 Subject: [PATCH 18/24] Add the missing defaults from for_test --- tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tox.ini b/tox.ini index 48e86eda..218f6722 100644 --- a/tox.ini +++ b/tox.ini @@ -25,6 +25,9 @@ commands = clean: rm -rf build/ .cache/ dist/ .eggs/ pylint_django.egg-info/ .tox/ deps = coverage + django_tables2 + factory-boy + pytest django_is_installed: Django flake8: flake8 pylint: pylint From 1a1206610a38abae308dd1b96d6734fe2f2d9c94 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 19:56:08 -0800 Subject: [PATCH 19/24] Add more missing dependencies --- tox.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tox.ini b/tox.ini index 218f6722..8144b7c0 100644 --- a/tox.ini +++ b/tox.ini @@ -29,17 +29,22 @@ deps = factory-boy pytest django_is_installed: Django + django_is_installed: pylint flake8: flake8 pylint: pylint pylint: Django + pylint: pylint-plugin-utils 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-plugin-utils + django{111,20,21,22}: pylint django-master: Django 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 = . From 703ed34fd333a3ab9a77ca26ef2c96036175e8e8 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 20:34:15 -0800 Subject: [PATCH 20/24] Missing dep again --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 8144b7c0..3184c084 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ deps = factory-boy pytest django_is_installed: Django + django_is_installed: pylint-plugin-utils django_is_installed: pylint flake8: flake8 pylint: pylint From ff8e1e2d65f47a827248206f43a019a2244e9f47 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 20:36:09 -0800 Subject: [PATCH 21/24] What is happening? --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3184c084..4cc34d77 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ envlist = [testenv] commands = - django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py | grep django-not-available\' + django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py\' django_is_installed: pylint --load-plugins=pylint_django setup.py flake8: flake8 pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup From fba1a5670343cf3566c14a2a4fd8b2875686a0eb Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 20:40:57 -0800 Subject: [PATCH 22/24] Django_tables2 depends on django --- tox.ini | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 4cc34d77..eb3ecd5d 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ envlist = [testenv] commands = - django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py\' + django_not_installed: bash -c \'pylint --load-plugins=pylint_django setup.py | grep django-not-available\' django_is_installed: pylint --load-plugins=pylint_django setup.py flake8: flake8 pylint: pylint --rcfile=tox.ini -d missing-docstring,too-many-branches,too-many-return-statements,too-many-ancestors,fixme --ignore=tests pylint_django setup @@ -25,7 +25,6 @@ commands = clean: rm -rf build/ .cache/ dist/ .eggs/ pylint_django.egg-info/ .tox/ deps = coverage - django_tables2 factory-boy pytest django_is_installed: Django @@ -33,16 +32,19 @@ deps = django_is_installed: pylint flake8: flake8 pylint: pylint - pylint: Django 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-plugin-utils 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 From facd0b88c81b4b265bf0ec7414eaf967c9a095b9 Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 20:49:44 -0800 Subject: [PATCH 23/24] Remove debug messages --- pylint_django/tests/test_func.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pylint_django/tests/test_func.py b/pylint_django/tests/test_func.py index ecd52cf2..497aad83 100644 --- a/pylint_django/tests/test_func.py +++ b/pylint_django/tests/test_func.py @@ -5,8 +5,6 @@ import pylint -print('DEBUG: pylint version: {}'.format(pylint.__version__)) - # 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', '') @@ -39,7 +37,6 @@ # 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: - print("DEBUG: we should not enter this condition with pylint 2.5") # 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 From 1ef74539db4e004580e034a8662e52009c6d750b Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Sun, 24 Nov 2019 22:05:28 -0800 Subject: [PATCH 24/24] Fix the module full path when using foreign key in tests --- pylint_django/tests/input/func_noerror_foreign_key_package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint_django/tests/input/func_noerror_foreign_key_package.py b/pylint_django/tests/input/func_noerror_foreign_key_package.py index efa90c1b..d2e142da 100644 --- a/pylint_django/tests/input/func_noerror_foreign_key_package.py +++ b/pylint_django/tests/input/func_noerror_foreign_key_package.py @@ -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