I've been following Head First Python 2nd Edition and in chapter 4, a pep8 compliance testing is demonstrated. Despite having the same code as in book, my output is different.
Tested code is quite simple:
def search4vowels(phrase: str) -> set:
"""Return vowels found in supplied phrase."""
vowels = set('aeiou')
return vowels.intersection(set(phrase))
def search4letters(phrase: str, letters: str='aeiou') -> set:
"""Return a set of 'letters' found in 'phrase'."""
return set(letters).intersection(set(phrase))
I tried testing as shown in book, and got this output:
λ py.test.exe --pep8 vsearch.py
c:\users\gx\appdata\local\programs\python\python37-32\lib\site-packages\pep8.py:110: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
============================= test session starts =============================
platform win32 -- Python 3.7.4, pytest-5.1.1, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\gx\Desktop\H.F. Python\mymodules
plugins: pep8-1.0.6
collected 1 item
vsearch.py . [100%]
============================== warnings summary ===============================
c:\users\gx\appdata\local\programs\python\python37-32\lib\site-packages\_pytest\mark\structures.py:324
c:\users\gx\appdata\local\programs\python\python37-32\lib\site-packages\_pytest\mark\structures.py:324:
PytestUnknownMarkWarning: Unknown pytest.mark.pep8 - is this a typo?
You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning,
-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================== 1 passed, 1 warnings in 0.04s ========================
(I slightly modified whitespaces to make is more readable)
In the book no such thing is occurs. Before doing this I have freshly installed pytest and pytest-pep8 as shown in book.
What causes this?
This seems to be a known issue: #23. A workaround is either to register the pep8
marker in the pytest.ini
:
[pytest]
markers =
pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/
or to register it programmatically in the conftest.py
:
def pytest_configure(config):
config.addinivalue_line(
'markers', 'pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/'
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With