From 2045b495aa7e9d4d4246c2f0df74accc60466cce Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Tue, 21 Jul 2020 14:32:55 +0800 Subject: [PATCH 1/8] fix pylint bug --- .travis.yml | 2 ++ requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c7bdf56..509577a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: - "3.4" - "3.5" - "3.6" + - "3.7" + - "3.8" install: - pip install -r requirements.txt script: diff --git a/requirements.txt b/requirements.txt index 7eb8e88..d8856ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ codecov==2.0.9 mock==2.0.0 pylint==1.8.4 +isort==4.3.21 # https://github.com/PyCQA/pylint/pull/3725 pytest==3.5.1 pytest-cov==2.5.1 --e .[ci_tools] \ No newline at end of file +-e .[ci_tools] From 07eea1c87a062778e5de6519fe72de4459f807b5 Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Tue, 21 Jul 2020 14:38:15 +0800 Subject: [PATCH 2/8] remove unavailable Python 3.3 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 509577a..99c501d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" From 83b36fd427899cd53a67492c48689b3fcb7edf62 Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Tue, 21 Jul 2020 15:23:16 +0800 Subject: [PATCH 3/8] ignore ci_tools --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 99c501d..6270a76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: script: - pylint src/azure_devtools/scenario_tests - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then pylint src/azure_devtools/ci_tools --ignore=tests; fi; # CI tools is Py3.6 only - - pytest --cov=azure_devtools + - pytest --cov=azure_devtools src/azure_devtools/scenario_tests after_success: - codecov deploy: From 160239098f08830ac36ebf04d9940791fae1494a Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Wed, 22 Jul 2020 10:32:53 +0800 Subject: [PATCH 4/8] remove Python 3.4 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6270a76..93c48eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python python: - "2.7" - - "3.4" - "3.5" - "3.6" - "3.7" From 1df06ca8c88a244733448822bb5696e6c4e2e457 Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Wed, 22 Jul 2020 10:34:50 +0800 Subject: [PATCH 5/8] remove pylint on ci_tools --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 93c48eb..cf97ffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ install: - pip install -r requirements.txt script: - pylint src/azure_devtools/scenario_tests - - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then pylint src/azure_devtools/ci_tools --ignore=tests; fi; # CI tools is Py3.6 only - pytest --cov=azure_devtools src/azure_devtools/scenario_tests after_success: - codecov From 98b05429fb09d05510243a2944ff8e554697cd2c Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Wed, 22 Jul 2020 11:19:55 +0800 Subject: [PATCH 6/8] bump pylint to 2.5.3 --- pylintrc | 11 ++++++++--- requirements.txt | 2 +- src/azure_devtools/scenario_tests/base.py | 2 +- src/azure_devtools/scenario_tests/preparers.py | 2 +- .../scenario_tests/recording_processors.py | 4 ++-- .../scenario_tests/tests/test_utilities.py | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pylintrc b/pylintrc index 01ae42f..d565152 100644 --- a/pylintrc +++ b/pylintrc @@ -1,12 +1,18 @@ [MESSAGES CONTROL] # For all codes, run 'pylint --list-msgs' or go to 'http://pylint-messages.wikidot.com/all-codes' -# C0111 Missing docstring +# C0111 Missing docstring # C0103 Invalid %s name "%s" # I0011 Warning locally suppressed using disable-msg # W0511 fixme # R0401 Cyclic import (because of https://github.com/PyCQA/pylint/issues/850) # R0913 Too many arguments - Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods. -disable=C0111, C0103, W0511 +disable= + C0111, + C0103, + W0511, + R0401, + useless-object-inheritance, + import-outside-toplevel [FORMAT] max-line-length=120 @@ -23,4 +29,3 @@ init-import=yes [SIMILARITIES] min-similarity-lines=8 - diff --git a/requirements.txt b/requirements.txt index d8856ed..6031051 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ codecov==2.0.9 mock==2.0.0 -pylint==1.8.4 +pylint==2.5.3 isort==4.3.21 # https://github.com/PyCQA/pylint/pull/3725 pytest==3.5.1 pytest-cov==2.5.1 diff --git a/src/azure_devtools/scenario_tests/base.py b/src/azure_devtools/scenario_tests/base.py index 81d90f9..ee56a4e 100644 --- a/src/azure_devtools/scenario_tests/base.py +++ b/src/azure_devtools/scenario_tests/base.py @@ -195,7 +195,7 @@ def _process_response_recording(self, response): @classmethod def _custom_request_query_matcher(cls, r1, r2): """ Ensure method, path, and query parameters match. """ - from six.moves.urllib_parse import urlparse, parse_qs # pylint: disable=import-error,relative-import + from six.moves.urllib_parse import urlparse, parse_qs # pylint: disable=import-error url1 = urlparse(r1.uri) url2 = urlparse(r2.uri) diff --git a/src/azure_devtools/scenario_tests/preparers.py b/src/azure_devtools/scenario_tests/preparers.py index b10d8c9..a9ea756 100644 --- a/src/azure_devtools/scenario_tests/preparers.py +++ b/src/azure_devtools/scenario_tests/preparers.py @@ -97,7 +97,7 @@ def remove_resource_with_record_override(self, name, **kwargs): class SingleValueReplacer(RecordingProcessor): # pylint: disable=no-member def process_request(self, request): - from six.moves.urllib_parse import quote_plus # pylint: disable=import-error,relative-import + from six.moves.urllib_parse import quote_plus # pylint: disable=import-error if self.random_name in request.uri: request.uri = request.uri.replace(self.random_name, self.moniker) elif quote_plus(self.random_name) in request.uri: diff --git a/src/azure_devtools/scenario_tests/recording_processors.py b/src/azure_devtools/scenario_tests/recording_processors.py index b5e82a5..5b58bb8 100644 --- a/src/azure_devtools/scenario_tests/recording_processors.py +++ b/src/azure_devtools/scenario_tests/recording_processors.py @@ -95,8 +95,8 @@ def process_response(self, response): response['body']['string'] = \ "!!! The response body has been omitted from the recording because it is larger " \ - "than {} KB. It will be replaced with blank content of {} bytes while replay. " \ - "{}{}".format(self._max_response_body, length, self.control_flag, length) + "than {max_body} KB. It will be replaced with blank content of {length} bytes while replay. " \ + "{flag}{length}".format(max_body=self._max_response_body, length=length, flag=self.control_flag) return response diff --git a/src/azure_devtools/scenario_tests/tests/test_utilities.py b/src/azure_devtools/scenario_tests/tests/test_utilities.py index 0862ea1..712f4da 100644 --- a/src/azure_devtools/scenario_tests/tests/test_utilities.py +++ b/src/azure_devtools/scenario_tests/tests/test_utilities.py @@ -17,7 +17,7 @@ def test_create_random_name_default_value(self): self.assertTrue(isinstance(default_generated_name, str)) def test_create_random_name_randomness(self): - self.assertEqual(100, len(set([create_random_name() for _ in range(100)]))) + self.assertEqual(100, len({create_random_name() for _ in range(100)})) def test_create_random_name_customization(self): customized_name = create_random_name(prefix='pauline', length=61) @@ -74,7 +74,7 @@ def test_get_sha1_hash(self): And whistles in his sound. Last scene of all, That ends this strange eventful history, Is second childishness and mere oblivion, -Sans teeth, sans eyes, sans taste, sans everything. +Sans teeth, sans eyes, sans taste, sans everything. William Shakespeare """ From da1384fa7ee5d3feff25dcd79dff58a76a2c23ef Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Wed, 22 Jul 2020 12:57:58 +0800 Subject: [PATCH 7/8] make pylint compatibale with Python 2.7 --- pylintrc | 1 + requirements.txt | 3 ++- src/azure_devtools/scenario_tests/base.py | 2 +- src/azure_devtools/scenario_tests/preparers.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pylintrc b/pylintrc index d565152..890ffa8 100644 --- a/pylintrc +++ b/pylintrc @@ -7,6 +7,7 @@ # R0401 Cyclic import (because of https://github.com/PyCQA/pylint/issues/850) # R0913 Too many arguments - Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods. disable= + bad-option-value, C0111, C0103, W0511, diff --git a/requirements.txt b/requirements.txt index 6031051..29eddd5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ codecov==2.0.9 mock==2.0.0 -pylint==2.5.3 +pylint==2.5.3; python_version > '3' +pylint==1.8.4; python_version < '3' isort==4.3.21 # https://github.com/PyCQA/pylint/pull/3725 pytest==3.5.1 pytest-cov==2.5.1 diff --git a/src/azure_devtools/scenario_tests/base.py b/src/azure_devtools/scenario_tests/base.py index ee56a4e..6b4fd00 100644 --- a/src/azure_devtools/scenario_tests/base.py +++ b/src/azure_devtools/scenario_tests/base.py @@ -195,7 +195,7 @@ def _process_response_recording(self, response): @classmethod def _custom_request_query_matcher(cls, r1, r2): """ Ensure method, path, and query parameters match. """ - from six.moves.urllib_parse import urlparse, parse_qs # pylint: disable=import-error + from six.moves.urllib_parse import urlparse, parse_qs # pylint: disable=import-error, relative-import url1 = urlparse(r1.uri) url2 = urlparse(r2.uri) diff --git a/src/azure_devtools/scenario_tests/preparers.py b/src/azure_devtools/scenario_tests/preparers.py index a9ea756..593e1b4 100644 --- a/src/azure_devtools/scenario_tests/preparers.py +++ b/src/azure_devtools/scenario_tests/preparers.py @@ -97,7 +97,7 @@ def remove_resource_with_record_override(self, name, **kwargs): class SingleValueReplacer(RecordingProcessor): # pylint: disable=no-member def process_request(self, request): - from six.moves.urllib_parse import quote_plus # pylint: disable=import-error + from six.moves.urllib_parse import quote_plus # pylint: disable=import-error, relative-import if self.random_name in request.uri: request.uri = request.uri.replace(self.random_name, self.moniker) elif quote_plus(self.random_name) in request.uri: From 5c8243f5b02b567004ff880545b5692d0edfc55e Mon Sep 17 00:00:00 2001 From: Harold Zeng Date: Wed, 22 Jul 2020 13:00:33 +0800 Subject: [PATCH 8/8] fix test_text_payload --- src/azure_devtools/scenario_tests/tests/test_utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure_devtools/scenario_tests/tests/test_utilities.py b/src/azure_devtools/scenario_tests/tests/test_utilities.py index 712f4da..8fa6771 100644 --- a/src/azure_devtools/scenario_tests/tests/test_utilities.py +++ b/src/azure_devtools/scenario_tests/tests/test_utilities.py @@ -81,7 +81,7 @@ def test_get_sha1_hash(self): f.write(content) f.seek(0) hash_value = get_sha1_hash(f.name) - self.assertEqual('6487bbdbd848686338d729e6076da1a795d1ae747642bf906469c6ccd9e642f9', hash_value) + self.assertEqual('1a9ea462ce80aac3f1cacbdf59d3a630df01b933593a2c53bccc25ecc2569e31', hash_value) def test_text_payload(self): http_entity = mock.MagicMock()