def test_flake8_ok(): with tempfile.NamedTemporaryFile() as fp: fp.write(FLAKE8_TEST_FILE_OK) fp.flush() linter = linters.Flake8Linter() result = list(linter.check_files(fp.name)) assert result == []
def test_flake8_fail(): with tempfile.NamedTemporaryFile() as fp: fp.write(FLAKE8_TEST_FILE_FAIL) fp.flush() linter = linters.Flake8Linter() result = list(linter.check_files(fp.name)) expected = [ "{0}:3:9: F821 undefined name 'x'", "{0}:6:9: F821 undefined name 'y'", "{0}:7:1: E101 indentation contains mixed spaces and tabs", "{0}:7:1: W191 indentation contains tabs", ] expected = [s.format(fp.name) for s in expected] assert sorted(result) == sorted(expected)