Skip to content

Commit

Permalink
Merge pull request #134 from jamescooke/remove-doctest
Browse files Browse the repository at this point in the history
Remove doctest
  • Loading branch information
jamescooke committed Mar 6, 2020
2 parents 1db86b8 + a2b39c5 commit c5e8d51
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 34 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Unreleased_
See also `latest documentation
<https://flake8-aaa.readthedocs.io/en/latest/#__unreleased_marker__>`_.

Removed
.......

* Doctesting of internal helpers functions - not worth managing a whole tox
environment for when only two functions are being tested, and it's easier to
write the cases in pytest anyway. Tests moved to pytest.

0.8.1_ - 2020/03/01
-------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ dedent_closing_brackets = true
column_limit = 120

[tool:pytest]
addopts=--tb=short --color=yes --doctest-modules
addopts=--tb=short --color=yes
log_print=False
25 changes: 0 additions & 25 deletions src/flake8_aaa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,11 @@ def is_test_file(filename: str) -> bool:
"""
Check that path to file being checked passed by flake8 looks like a pytest
test file.
Examples:
1. Non-test files give False.
>>> is_test_file('./test.py')
False
>>> is_test_file('./helper.py')
False
>>> is_test_file('tests/conftest.py')
False
2. Finds files that start with 'test_' to be test files.
>>> is_test_file('./test_helpers.py')
True
"""
return os.path.basename(filename).startswith('test_')


def first_non_blank_char(line: str) -> int:
"""
Examples:
1. Empty string has no non-blank chars.
>>> first_non_blank_char('')
0
2. First char after whitespace or tabs works.
>>> first_non_blank_char(' return')
4
>>> first_non_blank_char(' return')
8
"""
for pos, char in enumerate(line):
if not char.isspace():
return pos
Expand Down
19 changes: 19 additions & 0 deletions tests/helpers/test_first_non_blank_char.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest

from flake8_aaa.helpers import first_non_blank_char


@pytest.mark.parametrize(
'line, char_index',
[
# Empty string has no non-blank chars.
('', 0),
# First char after whitespace or tabs works.
(' return', 4),
(' return', 8),
]
)
def test(line, char_index):
result = first_non_blank_char(line)

assert result == char_index
20 changes: 20 additions & 0 deletions tests/helpers/test_is_test_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from flake8_aaa.helpers import is_test_file


@pytest.mark.parametrize(
'path, expected_result',
[
# Non-test files give False.
('./test.py', False),
('./helper.py', False),
('tests/conftest.py', False),
# Finds files that start with 'test_' to be test files.
('./test_helpers.py', True),
]
)
def test(path, expected_result):
result = is_test_file(path)

assert result is expected_result
2 changes: 1 addition & 1 deletion tests/line_markers/test_check_act_assert_spacing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Generator
from collections.abc import Generator

from flake8_aaa.exceptions import AAAError
from flake8_aaa.line_markers import LineMarkers
Expand Down
2 changes: 1 addition & 1 deletion tests/line_markers/test_check_arrange_act_spacing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Generator
from collections.abc import Generator

from flake8_aaa.exceptions import AAAError
from flake8_aaa.line_markers import LineMarkers
Expand Down
9 changes: 3 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Run pytest on test suite.

[tox]
envlist = py3{6,7,8}-{install,lint,lintexamples,test,doctest,cmd,cmdbad},py36-doc
envlist = py3{6,7,8}-{install,lint,lintexamples,test,cmd,cmdbad},py36-doc

[install]
commands =
Expand All @@ -36,17 +36,14 @@ commands =

[testenv]
deps =
doc,doctest,lint,test: -rrequirements/base.txt
doc,doctest,lint,test: -rrequirements/test.txt
doc,lint,test: -rrequirements/base.txt
doc,lint,test: -rrequirements/test.txt
lintexamples: -rrequirements/lintexamples.txt
install: flake8>=3
changedir =
doctest: src/flake8_aaa
commands =
cmd: make cmd
cmdbad: make cmdbad
doc: make doc
doctest: pytest
install: {[install]commands}
lint: make lint
lintexamples: make lintexamples
Expand Down

0 comments on commit c5e8d51

Please sign in to comment.