Changes for new pylint compliance
This commit is contained in:
parent
f9e0368385
commit
8a87f4a30f
6 changed files with 33 additions and 32 deletions
|
@ -3,10 +3,10 @@
|
|||
import collections
|
||||
import contextlib
|
||||
import copy
|
||||
import distutils.dir_util # pylint: disable=no-name-in-module,import-error
|
||||
import os
|
||||
import platform
|
||||
import pwd
|
||||
import shutil
|
||||
from subprocess import Popen, PIPE
|
||||
import py
|
||||
import pytest
|
||||
|
@ -31,7 +31,7 @@ def shellcheck_version():
|
|||
@pytest.fixture(scope='session')
|
||||
def pylint_version():
|
||||
"""Version of pylint supported"""
|
||||
return '2.6.0'
|
||||
return '2.17.0'
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
|
@ -204,7 +204,7 @@ class Runner():
|
|||
merged_env.update(env)
|
||||
self.inp = inp
|
||||
self.wrap(expect)
|
||||
process = Popen(
|
||||
with Popen(
|
||||
self.command,
|
||||
stdin=PIPE,
|
||||
stdout=PIPE,
|
||||
|
@ -212,14 +212,14 @@ class Runner():
|
|||
shell=shell,
|
||||
cwd=cwd,
|
||||
env=merged_env,
|
||||
)
|
||||
input_bytes = self.inp
|
||||
if self.inp:
|
||||
input_bytes = self.inp.encode()
|
||||
(out_bstream, err_bstream) = process.communicate(input=input_bytes)
|
||||
self.out = out_bstream.decode()
|
||||
self.err = err_bstream.decode()
|
||||
self.code = process.wait()
|
||||
) as process:
|
||||
input_bytes = self.inp
|
||||
if self.inp:
|
||||
input_bytes = self.inp.encode()
|
||||
(out_bstream, err_bstream) = process.communicate(input=input_bytes)
|
||||
self.out = out_bstream.decode()
|
||||
self.err = err_bstream.decode()
|
||||
self.code = process.wait()
|
||||
self.success = self.code == 0
|
||||
self.failure = self.code != 0
|
||||
if report:
|
||||
|
@ -365,6 +365,10 @@ def yadm_cmd(paths):
|
|||
return command_list
|
||||
|
||||
|
||||
class NoRelativePath(Exception):
|
||||
"""Exception when finding relative paths"""
|
||||
|
||||
|
||||
class DataFile():
|
||||
"""Datafile object"""
|
||||
|
||||
|
@ -384,7 +388,7 @@ class DataFile():
|
|||
"""Relative path property"""
|
||||
if self.__parent:
|
||||
return self.__parent.join(self.path)
|
||||
raise BaseException('Unable to provide relative path, no parent')
|
||||
raise NoRelativePath('Unable to provide relative path, no parent')
|
||||
|
||||
@property
|
||||
def tracked(self):
|
||||
|
@ -405,10 +409,10 @@ class DataSet():
|
|||
"""Dataset object"""
|
||||
|
||||
def __init__(self):
|
||||
self.__files = list()
|
||||
self.__dirs = list()
|
||||
self.__tracked_dirs = list()
|
||||
self.__private_dirs = list()
|
||||
self.__files = []
|
||||
self.__dirs = []
|
||||
self.__tracked_dirs = []
|
||||
self.__private_dirs = []
|
||||
self.__relpath = None
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -562,15 +566,13 @@ def ds1_data(tmpdir_factory, config_git, ds1_dset, runner):
|
|||
@pytest.fixture()
|
||||
def ds1_work_copy(ds1_data, paths):
|
||||
"""Function scoped copy of ds1_data.work"""
|
||||
distutils.dir_util.copy_tree( # pylint: disable=no-member
|
||||
str(ds1_data.work), str(paths.work))
|
||||
shutil.copytree(str(ds1_data.work), str(paths.work), dirs_exist_ok=True)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def ds1_repo_copy(runner, ds1_data, paths):
|
||||
"""Function scoped copy of ds1_data.repo"""
|
||||
distutils.dir_util.copy_tree( # pylint: disable=no-member
|
||||
str(ds1_data.repo), str(paths.repo))
|
||||
shutil.copytree(str(ds1_data.repo), str(paths.repo), dirs_exist_ok=True)
|
||||
env = os.environ.copy()
|
||||
env['GIT_DIR'] = str(paths.repo)
|
||||
runner(
|
||||
|
|
|
@ -26,7 +26,7 @@ def test_pylint(pytestconfig, runner, pylint_version):
|
|||
run = runner(command=['pylint', '--version'], report=False)
|
||||
if f'pylint {pylint_version}' not in run.out:
|
||||
pytest.skip('Unsupported pylint version')
|
||||
pyfiles = list()
|
||||
pyfiles = []
|
||||
for tfile in os.listdir('test'):
|
||||
if tfile.endswith('.py'):
|
||||
pyfiles.append(f'test/{tfile}')
|
||||
|
|
|
@ -213,14 +213,14 @@ def test_score_values(
|
|||
local_user={local_user}
|
||||
"""
|
||||
expected = ''
|
||||
for filename in filenames:
|
||||
for filename, score in filenames.items():
|
||||
script += f"""
|
||||
score_file "{filename}"
|
||||
echo "{filename}"
|
||||
echo "$score"
|
||||
"""
|
||||
expected += filename + '\n'
|
||||
expected += str(filenames[filename]) + '\n'
|
||||
expected += str(score) + '\n'
|
||||
run = runner(command=['bash'], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
|
@ -278,14 +278,14 @@ def test_score_values_templates(runner, yadm):
|
|||
local_user={local_user}
|
||||
"""
|
||||
expected = ''
|
||||
for filename in filenames:
|
||||
for filename, score in filenames.items():
|
||||
script += f"""
|
||||
score_file "{filename}"
|
||||
echo "{filename}"
|
||||
echo "$score"
|
||||
"""
|
||||
expected += filename + '\n'
|
||||
expected += str(filenames[filename]) + '\n'
|
||||
expected += str(score) + '\n'
|
||||
run = runner(command=['bash'], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
|
@ -337,14 +337,14 @@ def test_underscores_in_distro_and_family(runner, yadm):
|
|||
local_distro_family="{local_distro_family}"
|
||||
"""
|
||||
expected = ''
|
||||
for filename in filenames:
|
||||
for filename, score in filenames.items():
|
||||
script += f"""
|
||||
score_file "{filename}"
|
||||
echo "{filename}"
|
||||
echo "$score"
|
||||
"""
|
||||
expected += filename + '\n'
|
||||
expected += str(filenames[filename]) + '\n'
|
||||
expected += str(score) + '\n'
|
||||
run = runner(command=['bash'], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
|
|
|
@ -39,7 +39,7 @@ def test_upgrade(tmpdir, runner, versions, submodule):
|
|||
os.environ.pop('XDG_DATA_HOME', None)
|
||||
|
||||
def run_version(version, *args, check_stderr=True):
|
||||
yadm = 'yadm-%s' % version if version else '/yadm/yadm'
|
||||
yadm = f'yadm-{version}' if version else '/yadm/yadm'
|
||||
run = runner([yadm, *args], shell=True, cwd=str(home), env=env)
|
||||
assert run.success
|
||||
if check_stderr:
|
||||
|
|
|
@ -10,9 +10,8 @@ def expected_version(yadm):
|
|||
Expected semantic version number. This is taken directly out of yadm,
|
||||
searching for the VERSION= string.
|
||||
"""
|
||||
yadm_version = re.findall(
|
||||
r'VERSION=([^\n]+)',
|
||||
open(yadm).read())
|
||||
with open(yadm, encoding='utf-8') as source_file:
|
||||
yadm_version = re.findall(r'VERSION=([^\n]+)', source_file.read())
|
||||
if yadm_version:
|
||||
return yadm_version[0]
|
||||
pytest.fail(f'version not found in {yadm}')
|
||||
|
|
|
@ -81,7 +81,7 @@ def parse_alt_output(output, linked=True):
|
|||
regex = r'Creating (.+) from template (.+)$'
|
||||
if linked:
|
||||
regex = r'Linking (.+) to (.+)$'
|
||||
parsed_list = dict()
|
||||
parsed_list = {}
|
||||
for line in output.splitlines():
|
||||
match = re.match(regex, line)
|
||||
if match:
|
||||
|
|
Loading…
Reference in a new issue