test_style.py 976 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. from __future__ import unicode_literals
  10. import os
  11. import subprocess
  12. import sys
  13. import unittest
  14. REPO_PATH = os.path.abspath(
  15. os.path.join(os.path.dirname(__file__), '..', 'pagure'))
  16. class TestStyle(unittest.TestCase):
  17. """This test class contains tests pertaining to code style."""
  18. def test_code_with_flake8(self):
  19. """Enforce PEP-8 compliance on the codebase.
  20. This test runs flake8 on the code, and will fail if it returns a non-zero exit code.
  21. """
  22. # We ignore E712, which disallows non-identity comparisons with True and False
  23. flake8_command = [sys.executable, '-m', 'flake8', '--ignore=E712,W503', REPO_PATH]
  24. self.assertEqual(subprocess.call(flake8_command), 0)
  25. if __name__ == '__main__':
  26. unittest.main(verbosity=2)