Blame tests/test_style.py
|
Pierre-Yves Chibon |
bd1fbf |
import os
|
|
Pierre-Yves Chibon |
bd1fbf |
import subprocess
|
|
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
|
|
Pierre-Yves Chibon |
bd1fbf |
flake8_command = ['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)
|