Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run flake8 as a test #142

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/test_flake8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pathlib
import unittest

from flake8.api import legacy as flake8

test_modules = ['rsa', 'tests']


class Flake8RunnerTest(unittest.TestCase):
def test_run_flake8(self):
proj_root = pathlib.Path(__file__).parent.parent
paths = [str(proj_root / dirname) for dirname in test_modules]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that Python 3.5 is EOL, is this still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify, what exactly do you mean? Conversion to a str?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.


style_guide = flake8.get_style_guide()
report = style_guide.check_files(paths)

errors = report.get_statistics('')
if errors:
self.fail('\n'.join(['Flake8 errors:'] + errors))