Blame tests/test_style.py

Pierre-Yves Chibon 393f31
#!/usr/bin/env python
Pierre-Yves Chibon 393f31
# -*- coding: utf-8 -*-
Pierre-Yves Chibon 393f31
Pierre-Yves Chibon 393f31
"""
Pierre-Yves Chibon 393f31
 (c) 2017 - Copyright Red Hat Inc
Pierre-Yves Chibon 393f31
Pierre-Yves Chibon 393f31
 Authors:
Pierre-Yves Chibon 393f31
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon 393f31
Pierre-Yves Chibon 393f31
Tests for flake8 compliance of the code
Pierre-Yves Chibon 393f31
Pierre-Yves Chibon 393f31
"""
Pierre-Yves Chibon 393f31
Pierre-Yves Chibon bd1fbf
import os
Pierre-Yves Chibon bd1fbf
import subprocess
Shengjing Zhu 77a68b
import sys
Pierre-Yves Chibon bd1fbf
import unittest
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
REPO_PATH = os.path.abspath(
Pierre-Yves Chibon bd1fbf
    os.path.join(os.path.dirname(__file__), '..', 'pagure'))
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
class TestStyle(unittest.TestCase):
Pierre-Yves Chibon bd1fbf
    """This test class contains tests pertaining to code style."""
Pierre-Yves Chibon bd1fbf
    def test_code_with_flake8(self):
Pierre-Yves Chibon bd1fbf
        """Enforce PEP-8 compliance on the codebase.
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
        This test runs flake8 on the code, and will fail if it returns a non-zero exit code.
Pierre-Yves Chibon bd1fbf
        """
Pierre-Yves Chibon bd1fbf
        # We ignore E712, which disallows non-identity comparisons with True and False
Shengjing Zhu 77a68b
        flake8_command = [sys.executable, '-m', 'flake8', '--ignore=E712,W503', REPO_PATH]
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
        self.assertEqual(subprocess.call(flake8_command), 0)
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
Pierre-Yves Chibon bd1fbf
if __name__ == '__main__':
Pierre-Yves Chibon bd1fbf
    unittest.main(verbosity=2)