【发布时间】:2015-03-20 09:18:55
【问题描述】:
我无法从 Python 脚本运行 PEP8 检查。
我不想显式运行 pep8.exe,因为我想自动执行此检查,而 pep8 可执行文件可以位于不同平台上的不同位置。
【问题讨论】:
我无法从 Python 脚本运行 PEP8 检查。
我不想显式运行 pep8.exe,因为我想自动执行此检查,而 pep8 可执行文件可以位于不同平台上的不同位置。
【问题讨论】:
PEP8 advanced usage 涵盖在 Python 脚本中使用 pep8。
举个例子:
import unittest
import pep8
class TestCodeFormat(unittest.TestCase):
def test_pep8_conformance(self):
"""Test that we conform to PEP8."""
pep8style = pep8.StyleGuide(quiet=True)
result = pep8style.check_files(['file1.py', 'file2.py'])
self.assertEqual(result.total_errors, 0,
"Found code style errors (and warnings).")
【讨论】: