我一直在遵循headfirstpython第2版,在第4章中,演示了pep8遵从性测试。尽管代码和书中的代码相同,但我的输出是不同的。在
测试代码非常简单:
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))
我试着按书中所示进行测试,得到以下输出:
^{pr2}$(我稍微修改了空白,使其更具可读性)
在这本书里没有这样的事情发生。 在此之前,我已经安装了pytest和pytest-pep8,如书中所示。在
是什么原因造成的?在
这似乎是一个已知的问题:#23。解决方法是在
pytest.ini
中注册pep8
标记:或者以编程方式在
^{pr2}$conftest.py
中注册它:相关问题 更多 >
编程相关推荐