Skip to content

Commit

Permalink
pylint private unused variable cleanup/update tests to python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra Peisach committed Jul 4, 2021
1 parent eaa1298 commit be3e762
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 47 deletions.
14 changes: 7 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ schedules:

jobs:
- template: azure-template-tox-job.yml
parameters: {tox: 'format_pep8', python: '3.8', os: 'linux'}
parameters: {tox: 'format_pep8', python: '3.9', os: 'linux'}
- template: azure-template-tox-job.yml
parameters: {tox: 'lint_pylint', python: '3.8', os: 'linux'}
parameters: {tox: 'lint_pylint', python: '3.9', os: 'linux'}
- template: azure-template-tox-job.yml
parameters: {tox: 'test_coverage', python: '3.8', os: 'linux'}
parameters: {tox: 'test_coverage', python: '3.9', os: 'linux'}
#
- template: azure-template-tox-job.yml
parameters: {tox: 'py38', python: '3.8', os: 'linux'}
parameters: {tox: 'py39', python: '3.9', os: 'linux'}
- template: azure-template-tox-job.yml
parameters: {tox: 'py27', python: '2.7', os: 'linux'}
#
- template: azure-template-tox-job.yml
parameters: {tox: 'py38', python: '3.8', os: 'macos'}
parameters: {tox: 'py39', python: '3.9', os: 'macos'}
- template: azure-template-tox-job.yml
parameters: {tox: 'py27', python: '2.7', os: 'macos'}
#
# - template: azure-template-publish-job.yml
# parameters: {tox: 'py38', python: '3.8', os: 'macos'}
# parameters: {tox: 'py39', python: '3.9', os: 'macos'}
# - template: azure-template-publish-job.yml
# parameters: {tox: 'py38', python: '3.8', os: 'linux'}
# parameters: {tox: 'py39', python: '3.9', os: 'linux'}
#
- template: azure-template-publish-job.yml
parameters: {tox: 'py27', python: '2.7', os: 'macos'}
Expand Down
7 changes: 6 additions & 1 deletion azure-template-publish-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ parameters:

jobs:
- job: ${{ format('publish_{0}_{1}', parameters.tox, parameters.os) }}

variables:
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isDevelop: $[eq(variables['Build.SourceBranch'], 'refs/heads/develop')]

pool:
${{ if eq(parameters.os, 'macos') }}:
vmImage: 'macOS-10.14'
${{ if eq(parameters.os, 'linux') }}:
vmImage: 'ubuntu-latest'
dependsOn:
- ${{ format('build_test_{0}_{1}', parameters.tox, parameters.os) }}
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Push_Pypi'], 'True'))
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), or(eq(variables.isMaster, true), eq(variables.isDevelop, true)))
#
steps:
- task: UsePythonVersion@0
Expand Down
19 changes: 17 additions & 2 deletions azure-template-tox-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
vmImage: 'ubuntu-latest'

variables:
- group: py-shared-variables
group: py-shared-variables
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip

steps:
#
Expand Down Expand Up @@ -120,9 +121,18 @@ jobs:
- script: "python -c \"import sys; print(sys.version); print(sys.executable)\""
displayName: show python information
#
- script: python -m pip install --upgrade pip tox
- script: python -m pip install --upgrade pip tox wheel
displayName: 'Install tools'
#
- task: Cache@2
inputs:
key: 'python | "$(Agent.OS)" | requirements.txt'
restoreKeys: |
python | "$(Agent.OS)"
python
path: $(PIP_CACHE_DIR)
displayName: Cache pip packages

- script: pip install -r requirements.txt
displayName: 'Install dependencies'
#
Expand All @@ -131,6 +141,11 @@ jobs:
export CONFIG_SUPPORT_TOKEN_ENV=$(VAR_CONFIG_SUPPORT_TOKEN_ENV)
${{ format('python -m tox -e {0}', parameters.tox) }}
displayName: 'Running tox task'
- ${{ if and(not(startsWith(parameters.tox, 'py')), startsWith(parameters.python, '3.9')) }}:
- script: |
export CONFIG_SUPPORT_TOKEN_ENV=$(VAR_CONFIG_SUPPORT_TOKEN_ENV)
${{ format('python -m tox -e {0}-py39', parameters.tox) }}
displayName: 'Running tox task'
- ${{ if and(not(startsWith(parameters.tox, 'py')), startsWith(parameters.python, '3.8')) }}:
- script: |
export CONFIG_SUPPORT_TOKEN_ENV=$(VAR_CONFIG_SUPPORT_TOKEN_ENV)
Expand Down
34 changes: 15 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_pattern = "*Tests.py"
source_paths = wwpdb/utils/ws_utils wwpdb/utils/tests-ws_utils setup.py
#
# Start directory path for test discovery
# Each path must reference valid directory that is searchable by python3.8 (i.e. contains __init__.py)
# Each path must reference valid directory that is searchable by python3.9 (i.e. contains __init__.py)
# ** It is harmless to point to paths containing no tests.
#
test_path_1 = "wwpdb/utils/tests-ws_utils"
Expand All @@ -37,7 +37,7 @@ flake_exclude_paths = --exclude wwpdb/utils/tests-ws_utils/test-output
##
[tox]
# The complete list of supported test environments to setup and invoke
envlist = format_pep8-{py38}, lint_pylint-{py38}, format_black-{py38}, py{38,27}, test_coverage-{py38}
envlist = format_pep8-{py39}, lint_pylint-{py39}, format_black-{py39}, py{39,27}, test_coverage-{py39}
#
minversion = 3.4.0
skip_missing_interpreters = true
Expand All @@ -46,7 +46,7 @@ skipsdist = false
[testenv]
passenv = CONFIG_SUPPORT_TOKEN_ENV
whitelist_externals = echo
deps = echo
# deps = echo
commands =
echo "Starting default tests in testenv"

Expand All @@ -61,7 +61,7 @@ skip_install = false
recreate = true
alwayscopy=true
usedevelop=true
deps = echo
deps =
-r requirements.txt
commands =
echo "Starting {envname}"
Expand All @@ -72,18 +72,18 @@ commands =
{envpython} -m unittest discover -v --start-directory {[local_settings]test_path_4} --pattern "{[local_settings]test_pattern}"
echo "Completed {envname}"

[testenv:py38]
[testenv:py39]
description = 'Run unit tests (unittest runner) using {envpython}'
whitelist_externals = echo
platform=
macos: darwin
linux: linux
basepython = py38: python3.8
basepython = py39: python3.9
skip_install = false
recreate = true
alwayscopy=true
usedevelop=true
deps = echo
deps =
-r requirements.txt
commands =
echo "Starting {envname}"
Expand All @@ -95,15 +95,14 @@ commands =
echo "Completed {envname}"

#
[testenv:format_pep8-py38]
[testenv:format_pep8-py39]
description = 'Run selected PEP8 compliance checks (flake8)'
platform=
macos: darwin
linux: linux
whitelist_externals = echo
basepython = py38: python3.8
basepython = py39: python3.9
deps =
echo
flake8
# This plugin is no longer compatible with latest pydocstyles -
# flake8-docstrings>=0.2.7
Expand All @@ -114,16 +113,15 @@ commands =
flake8 --max-line-length=185 --ignore=D,I,E203,W503 {[local_settings]source_paths} {[local_settings]flake_exclude_paths}

#
[testenv:lint_pylint-py38]
[testenv:lint_pylint-py39]
description = 'Run linting compliance checks (pylint)'
platform=
macos: darwin
linux: linux
whitelist_externals = echo
basepython3.8 = py38: python3.8
basepython3.9 = py39: python3.9

deps =
echo
pylint
-r requirements.txt
commands =
Expand All @@ -132,15 +130,14 @@ commands =
echo "Completed {envname}"

#
[testenv:format_black-py38]
[testenv:format_black-py39]
description = 'Run format compliance checks (black)'
platform=
macos: darwin
linux: linux
whitelist_externals = echo
basepython3.8 = py38: python3.8
basepython3.9 = py39: python3.9
deps =
echo
black>=19.10b0
-r requirements.txt
# isort>=4.3.20
Expand All @@ -151,18 +148,17 @@ commands =
echo "Completed {envname}"

#
[testenv:test_coverage-py38]
[testenv:test_coverage-py39]
description = 'Run test coverage analysis'
platform=
macos: darwin
linux: linux
whitelist_externals = echo
basepython = py38: python3.8
basepython = py39: python3.9
recreate = true
alwayscopy=true
usedevelop=true
deps =
echo
coverage
-r requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion wwpdb/utils/tests-ws_utils/ServiceDataStoreTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setUp(self):
os.makedirs(self.__sessdir)

def testInstantiate(self):
""" Test acquiring new or existing token"""
"""Test acquiring new or existing token"""
tfile = os.path.join(self.__sessdir, "test1-session-store.pic")
if os.path.exists(tfile):
os.unlink(tfile)
Expand Down
2 changes: 1 addition & 1 deletion wwpdb/utils/tests-ws_utils/ServiceHistoryTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setUp(self):
os.makedirs(self.__histpath) # pragma: no cover

def testHistory(self):
""" Test acquiring new or existing token"""
"""Test acquiring new or existing token"""
tfile = os.path.join(self.__histpath, "history-session-store.pic")
if os.path.exists(tfile):
os.unlink(tfile)
Expand Down
6 changes: 3 additions & 3 deletions wwpdb/utils/tests-ws_utils/ServiceResponseTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ def setUp(self):
self.__sr = ServiceResponse()

def testSetError(self):
""" Test setting error"""
"""Test setting error"""
self.assertFalse(self.__sr.isError())
self.__sr.setError(statusCode=200, msg="Some error")
self.assertTrue(self.__sr.isError())

def testSetData(self):
""" Test setting data"""
"""Test setting data"""
self.assertEqual(self.__sr.getData(), {})
dt = {"1": 2}
self.__sr.setData(dt)
self.assertEqual(self.__sr.getData(), dt)

def testHtml(self):
""" Test html list actions"""
"""Test html list actions"""
self.__sr.setHtmlList()
self.__sr.setHtmlList(["Test file is foo.py", "Of two items"])
self.__sr.appendHtmlList(["Some other data", "with two items"])
Expand Down
2 changes: 1 addition & 1 deletion wwpdb/utils/tests-ws_utils/ServiceUtilsMiscTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self):
pass

def testMD5(self):
""" Test MD5 calculation"""
"""Test MD5 calculation"""
md5 = getMD5(__file__, block_size=50)
sys.stderr.write("MD5 size=50: %s\n" % md5)
md5_2 = getMD5(__file__)
Expand Down
16 changes: 8 additions & 8 deletions wwpdb/utils/tests-ws_utils/TokenUtilsTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setUp(self):
self.__tokenPrefix = "VALWS"

def testGetToken(self):
""" Test acquiring new or existing token"""
"""Test acquiring new or existing token"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
tokenId, jwtToken = tU.getToken("some.email@noreply.org")
logging.debug("tokenid %r is %r ", tokenId, jwtToken)
Expand All @@ -75,7 +75,7 @@ def testGetToken(self):
self.assertIsNotNone(tU.getFilePath())

def testTokenTimes(self):
""" Test token access creation and expiration dates"""
"""Test token access creation and expiration dates"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
tokenId, jwtToken = tU.getToken("john.westbrook@rcsb.org")
logging.debug("tokenid %r is %r ", tokenId, jwtToken)
Expand Down Expand Up @@ -116,7 +116,7 @@ def testGetManyTokens(self):
self.assertEqual(tokenId, tId)

def testRemoveTokens(self):
"""Test remove many tokens by token id """
"""Test remove many tokens by token id"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
for i in xrange(0, 100):
tokenId, jwtToken = tU.getToken("john.westbrook%04d@rcsb.org" % i)
Expand All @@ -127,7 +127,7 @@ def testRemoveTokens(self):

# Disabled - we do not want email in automated test
def NoSendToken(self): # pragma: no cover
"""Test acquire new or existing token and send token to recipient """
"""Test acquire new or existing token and send token to recipient"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
tokenId, jwtToken = tU.getToken("john.westbrook@rcsb.org")
logging.debug("tokenid %r is %r ", tokenId, jwtToken)
Expand Down Expand Up @@ -159,7 +159,7 @@ def NoSendToken(self): # pragma: no cover
self.assertEqual(ok, True)

def testParseAuth(self):
""" Test parsing authorization"""
"""Test parsing authorization"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
tokenId, jwtToken = tU.getToken("some.email@noreply.org")

Expand Down Expand Up @@ -188,7 +188,7 @@ def testParseAuth(self):
self.assertEqual(tD["sub"], tokenId)

def testTokenReaderParseToken(self):
""" Test parsing tokens from JwtTokenReader"""
"""Test parsing tokens from JwtTokenReader"""

tR = JwtTokenReader()
# Validate token
Expand All @@ -209,7 +209,7 @@ def testTokenReaderParseToken(self):
self.assertEqual(tD["errorMessage"], "API access token has expired")

def testTokenUtilsParseToken(self):
""" Test parsing tokens from TokenUtils"""
"""Test parsing tokens from TokenUtils"""

tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)

Expand All @@ -229,7 +229,7 @@ def testTokenUtilsParseToken(self):
self.assertEqual(tD["errorMessage"], "API access token has expired")

def testTokenUtilsParseAuth(self):
""" Test parsing authorization"""
"""Test parsing authorization"""
tU = MyJwtTokenUtils(tokenPrefix=self.__tokenPrefix)
tokenId, jwtToken = tU.getToken("some.email@noreply.org") # pylint: disable=unused-variable

Expand Down
2 changes: 0 additions & 2 deletions wwpdb/utils/ws_utils/ServiceDataStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def __init__(self, sessionPath, prefix=None):
self.__filePrefix = prefix if prefix is not None else "general"
self.__sessionPath = sessionPath
self.__filePath = None
self.__timeOutSeconds = 8.0
self.__retrySeconds = 0.2
#
lockutils.set_defaults(self.__sessionPath)
#
Expand Down
1 change: 0 additions & 1 deletion wwpdb/utils/ws_utils/ServiceRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def __init__(self, paramDict=None):
if paramDict is None:
paramDict = {}
self.__dict = paramDict
self.__debug = False

def __outputList(self):
sL = []
Expand Down
1 change: 0 additions & 1 deletion wwpdb/utils/ws_utils/ServiceResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def __init__(self, returnFormat="json", injectStatus=True):
if these are not set.
"""
self.__debug = False
self.__injectStatus = injectStatus
self._cD = self.__setup(returnFormat)

Expand Down

0 comments on commit be3e762

Please sign in to comment.