test_syntax.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """Syntax checks"""
  2. import os
  3. import pytest
  4. def test_yadm_syntax(runner, yadm):
  5. """Is syntactically valid"""
  6. run = runner(command=['bash', '-n', yadm])
  7. assert run.success
  8. def test_shellcheck(runner, yadm, shellcheck_version):
  9. """Passes shellcheck"""
  10. run = runner(command=['shellcheck', '-V'], report=False)
  11. if f'version: {shellcheck_version}' not in run.out:
  12. pytest.skip('Unsupported shellcheck version')
  13. run = runner(command=['shellcheck', '-s', 'bash', yadm])
  14. assert run.success
  15. def test_pylint(runner, pylint_version):
  16. """Passes pylint"""
  17. run = runner(command=['pylint', '--version'], report=False)
  18. if f'pylint {pylint_version}' not in run.out:
  19. pytest.skip('Unsupported pylint version')
  20. pyfiles = list()
  21. for tfile in os.listdir('test'):
  22. if tfile.endswith('.py'):
  23. pyfiles.append(f'test/{tfile}')
  24. run = runner(command=['pylint'] + pyfiles)
  25. assert run.success
  26. def test_flake8(runner, flake8_version):
  27. """Passes flake8"""
  28. run = runner(command=['flake8', '--version'], report=False)
  29. if not run.out.startswith(flake8_version):
  30. pytest.skip('Unsupported flake8 version')
  31. run = runner(command=['flake8', 'test'])
  32. assert run.success