Debian Codegraph @

debian/patches/linters.patch

raw
1 --- a/tests/test_infra.py
2 +++ b/tests/test_infra.py
3 @@ -15,63 +15,3 @@
4 # For further info, check https://github.com/PyAr/fades
5
6 """Tests for infrastructure stuff."""
7 -
8 -import io
9 -import logging
10 -from unittest.mock import patch
11 -
12 -import docutils.core
13 -import pydocstyle
14 -import pytest
15 -import rst2html5_
16 -from flake8.api.legacy import get_style_guide
17 -from pyuca import Collator
18 -
19 -from tests import get_python_filepaths
20 -
21 -FLAKE8_ROOTS = ['fades', 'tests']
22 -FLAKE8_OPTIONS = {'max_line_length': 99, 'select': ['E', 'W', 'F', 'C', 'N']}
23 -PEP257_ROOTS = ['fades']
24 -
25 -# avoid seeing all DEBUG logs if the test fails
26 -for logger_name in ('flake8.plugins', 'flake8.api', 'flake8.checker', 'flake8.main'):
27 - logging.getLogger(logger_name).setLevel(logging.CRITICAL)
28 -
29 -
30 -def test_flake8_pytest(capsys):
31 - python_filepaths = get_python_filepaths(FLAKE8_ROOTS)
32 - style_guide = get_style_guide(**FLAKE8_OPTIONS)
33 - report = style_guide.check_files(python_filepaths)
34 - if report.total_errors != 0:
35 - out, _ = capsys.readouterr()
36 - pytest.fail(f"There are {report.total_errors} issues!\n{''.join(out)}")
37 -
38 -
39 -def test_pep257_pytest():
40 - python_filepaths = get_python_filepaths(PEP257_ROOTS)
41 - to_ignore = {
42 - "D105", # Missing docstring in magic method
43 - "D107", # Missing docstring in __init__
44 - }
45 - to_include = pydocstyle.violations.conventions.pep257 - to_ignore
46 - result = list(pydocstyle.check(python_filepaths, select=to_include))
47 - assert len(result) == 0, "There are issues!\n" + '\n'.join(map(str, result))
48 -
49 -
50 -def test_readme_sanity():
51 - fake_stdout = io.StringIO() # just to ignore the output
52 - fake_stderr = io.StringIO() # will have content if there are problems
53 - with open('README.rst', 'rt', encoding='utf8') as fh:
54 - with patch('sys.stdout', fake_stdout):
55 - with patch('sys.stderr', fake_stderr):
56 - docutils.core.publish_file(source=fh, writer=rst2html5_.HTML5Writer())
57 -
58 - errors = fake_stderr.getvalue()
59 - assert not bool(errors), "There are issues!\n" + errors
60 -
61 -
62 -def test_authors_ordering():
63 - with open('AUTHORS', 'rt', encoding='utf8') as fh:
64 - authors = fh.readlines()
65 - ordered_authors = sorted(authors, key=Collator().sort_key)
66 - assert authors == ordered_authors