Skip to content

Commit

Permalink
Merge pull request #120 from life4/flake8-integration-test
Browse files Browse the repository at this point in the history
Integration test for flake8
  • Loading branch information
orsinium authored Sep 1, 2022
2 parents 4cb8208 + b8c1f8e commit 5a61858
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ all = [
test = [
"coverage[toml]",
"docstring-parser",
"flake8",
"isort",
"marshmallow",
"pytest-cov",
Expand Down
20 changes: 18 additions & 2 deletions tests/test_linter/test_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import ast
from pathlib import Path
import subprocess
import sys
from textwrap import dedent

from deal.linter import Checker
Expand Down Expand Up @@ -56,11 +58,12 @@ def test_get_funcs_invalid_syntax(tmp_path: Path):


def test_version():
version = Checker(tree=None, filename='stdin').version
version = Checker.version
assert len(version) >= 5
assert not set(version) - set('0123456789.')


def test_remove_duplicates(tmp_path):
def test_remove_duplicates(tmp_path: Path):
text = """
import deal
Expand All @@ -77,3 +80,16 @@ def outer():
checker = Checker(tree=ast.parse(TEXT), filename=str(path))
errors = list(checker.run())
assert len(errors) == 1


def test_flake8_integration(tmp_path: Path):
path = tmp_path / 'test.py'
path.write_text(TEXT + '\n')
cmd = [sys.executable, '-m', 'flake8', str(tmp_path)]
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert result.returncode == 1
lines = result.stdout.decode().splitlines()
assert len(EXPECTED) == len(lines), result.stderr
for (lineno, col, error, _), line in zip(EXPECTED, lines):
assert error in line
assert f':{lineno}:{col + 1}' in line
1 change: 1 addition & 0 deletions tests/test_schemes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

import marshmallow
import pytest
import vaa
Expand Down

0 comments on commit 5a61858

Please sign in to comment.