mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00:00
Add --force-linters option to pylint (#179)
When this option is provided, linters will be run regardless of the version installed. Normally tests are skipped if the linters are not the supported version.
This commit is contained in:
parent
5d484ca825
commit
437ae2b719
@ -12,6 +12,16 @@ import py
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_addoption(parser):
|
||||||
|
"""Add options to pytest"""
|
||||||
|
parser.addoption(
|
||||||
|
"--force-linters",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Run linters regardless of installed versions",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def shellcheck_version():
|
def shellcheck_version():
|
||||||
"""Version of shellcheck supported"""
|
"""Version of shellcheck supported"""
|
||||||
|
@ -10,20 +10,22 @@ def test_yadm_syntax(runner, yadm):
|
|||||||
assert run.success
|
assert run.success
|
||||||
|
|
||||||
|
|
||||||
def test_shellcheck(runner, yadm, shellcheck_version):
|
def test_shellcheck(pytestconfig, runner, yadm, shellcheck_version):
|
||||||
"""Passes shellcheck"""
|
"""Passes shellcheck"""
|
||||||
run = runner(command=['shellcheck', '-V'], report=False)
|
if not pytestconfig.getoption("--force-linters"):
|
||||||
if f'version: {shellcheck_version}' not in run.out:
|
run = runner(command=['shellcheck', '-V'], report=False)
|
||||||
pytest.skip('Unsupported shellcheck version')
|
if f'version: {shellcheck_version}' not in run.out:
|
||||||
|
pytest.skip('Unsupported shellcheck version')
|
||||||
run = runner(command=['shellcheck', '-s', 'bash', yadm])
|
run = runner(command=['shellcheck', '-s', 'bash', yadm])
|
||||||
assert run.success
|
assert run.success
|
||||||
|
|
||||||
|
|
||||||
def test_pylint(runner, pylint_version):
|
def test_pylint(pytestconfig, runner, pylint_version):
|
||||||
"""Passes pylint"""
|
"""Passes pylint"""
|
||||||
run = runner(command=['pylint', '--version'], report=False)
|
if not pytestconfig.getoption("--force-linters"):
|
||||||
if f'pylint {pylint_version}' not in run.out:
|
run = runner(command=['pylint', '--version'], report=False)
|
||||||
pytest.skip('Unsupported pylint version')
|
if f'pylint {pylint_version}' not in run.out:
|
||||||
|
pytest.skip('Unsupported pylint version')
|
||||||
pyfiles = list()
|
pyfiles = list()
|
||||||
for tfile in os.listdir('test'):
|
for tfile in os.listdir('test'):
|
||||||
if tfile.endswith('.py'):
|
if tfile.endswith('.py'):
|
||||||
@ -32,20 +34,22 @@ def test_pylint(runner, pylint_version):
|
|||||||
assert run.success
|
assert run.success
|
||||||
|
|
||||||
|
|
||||||
def test_flake8(runner, flake8_version):
|
def test_flake8(pytestconfig, runner, flake8_version):
|
||||||
"""Passes flake8"""
|
"""Passes flake8"""
|
||||||
run = runner(command=['flake8', '--version'], report=False)
|
if not pytestconfig.getoption("--force-linters"):
|
||||||
if not run.out.startswith(flake8_version):
|
run = runner(command=['flake8', '--version'], report=False)
|
||||||
pytest.skip('Unsupported flake8 version')
|
if not run.out.startswith(flake8_version):
|
||||||
|
pytest.skip('Unsupported flake8 version')
|
||||||
run = runner(command=['flake8', 'test'])
|
run = runner(command=['flake8', 'test'])
|
||||||
assert run.success
|
assert run.success
|
||||||
|
|
||||||
|
|
||||||
def test_yamllint(runner, yamllint_version):
|
def test_yamllint(pytestconfig, runner, yamllint_version):
|
||||||
"""Passes yamllint"""
|
"""Passes yamllint"""
|
||||||
run = runner(command=['yamllint', '--version'], report=False)
|
if not pytestconfig.getoption("--force-linters"):
|
||||||
if not run.out.strip().endswith(yamllint_version):
|
run = runner(command=['yamllint', '--version'], report=False)
|
||||||
pytest.skip('Unsupported yamllint version')
|
if not run.out.strip().endswith(yamllint_version):
|
||||||
|
pytest.skip('Unsupported yamllint version')
|
||||||
run = runner(
|
run = runner(
|
||||||
command=['yamllint', '-s', '$(find . -name \\*.yml)'],
|
command=['yamllint', '-s', '$(find . -name \\*.yml)'],
|
||||||
shell=True)
|
shell=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user