Читал книгу "Изучаем программирование на Python автор Бэрри П.".
В книге было задание проверить код на соответствие правилам PEP8.
По инструкции в книге я установил pytest pip install pytest
и плагин к нему pytest-pep8 pip install pytest-pep8
. Все установилось успешно.
Далее я запустил проверку своего модуля в командной строке py.test --pep8 D:\code\HeadFirst\webapp\vsearch.py
результат:
C:\Users\titelivus>py.test --pep8 D:\code\HeadFirst\webapp\vsearch.py
c:\python\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.8.3, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\titelivus
plugins: pep8-1.0.6
collected 0 items / 1 error
==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
c:\python\lib\site-packages\pluggy\hooks.py:286: in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
c:\python\lib\site-packages\pluggy\manager.py:93: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
c:\python\lib\site-packages\pluggy\manager.py:84: in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
c:\python\lib\site-packages\pytest_pep8.py:38: in pytest_collect_file
return Pep8Item(path, parent, pep8ignore, config._max_line_length)
c:\python\lib\site-packages\_pytest\nodes.py:95: in __call__
warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
E pytest.PytestDeprecationWarning: Direct construction of Pep8Item has been deprecated, please use Pep8Item.from_parent.
E See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.
=========================== short test summary info ============================
ERROR - pytest.PytestDeprecationWarning: Direct construction of Pep8Item has ...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.14s ===============================
Я внимательно прочитал текст ошибки, перешел по указанной ссылке, прочитал ее решение, но оно для меня не было понятным.
Нужно в каком то файле (догадываюсь что здесь c:\python\lib\site-packages\pytest_pep8.py:38: in pytest_collect_file
), что-то изменить, чтобы все заработало.