test_style.py 935 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. (c) 2017 - Copyright Red Hat Inc
  5. Authors:
  6. Pierre-Yves Chibon <pingou@pingoured.fr>
  7. Tests for flake8 compliance of the code
  8. """
  9. import os
  10. import subprocess
  11. import sys
  12. import unittest
  13. REPO_PATH = os.path.abspath(
  14. os.path.join(os.path.dirname(__file__), '..', 'pagure'))
  15. class TestStyle(unittest.TestCase):
  16. """This test class contains tests pertaining to code style."""
  17. def test_code_with_flake8(self):
  18. """Enforce PEP-8 compliance on the codebase.
  19. This test runs flake8 on the code, and will fail if it returns a non-zero exit code.
  20. """
  21. # We ignore E712, which disallows non-identity comparisons with True and False
  22. flake8_command = [sys.executable, '-m', 'flake8', '--ignore=E712,W503', REPO_PATH]
  23. self.assertEqual(subprocess.call(flake8_command), 0)
  24. if __name__ == '__main__':
  25. unittest.main(verbosity=2)