Commit e8994144 authored by Denis Bilenko's avatar Denis Bilenko

greentest: add xtest_pep8.py

parent b059f651
import sys
import os
import unittest
import glob
import re
from os.path import abspath, dirname, join, basename
# this regex matches filenames of the standard tests (with one underscore)
stdtest_re = re.compile('^(test_[^_].+|lock_tests)\.py$')
script = 'pep8'
try:
index = sys.argv.index('--script')
except ValueError:
pass
else:
script = sys.argv[index + 1]
del sys.argv[index:index + 2]
# E501 line too long (80 character limit that we don't follow)
command = script + ' --repeat --statistics --ignore E501 %s | grep -v E501'
if os.system('pep8 --version'):
sys.stderr.write('Please install pep8 script\n')
sys.exit(0)
def system(*args):
command = ' '.join(args)
popen_result = os.popen(command)
result = popen_result.read()
if result:
sys.stderr.write(result)
raise AssertionError('pep8 failed')
class Test(unittest.TestCase):
def test_gevent(self):
import gevent
# E221 multiple spaces before operator
system(command % join(abspath(dirname(gevent.__file__)), '*.py'), '| grep -v E221')
def test_tests(self):
# E702 multiple statements on one line (from gevent import monkey; monkey.patch_all())
files = glob.glob(join(abspath(dirname(__file__)), '*.py'))
# filter out standard tests of form test_xxx.py (one underscore)
files = [filename for filename in files if stdtest_re.match(basename(filename)) is None]
system(command % (' '.join(files)), '| grep -v E702')
# we keep the standard tests as close to the originals as possible, so don't test them
def X_test_std_tests(self):
# E702 multiple statements on one line (from gevent import monkey; monkey.patch_all())
files = glob.glob(join(abspath(dirname(__file__)), '*.py'))
# only count standard tests of form test_xxx.py (one underscore)
files = [filename for filename in files if stdtest_re.match(basename(filename)) is not None]
system(command % (' '.join(files)), '| grep -v E702')
def test_examples(self):
# E702 multiple statements on one line (from gevent import monkey; monkey.patch_all())
system(command % join(dirname(abspath(dirname(__file__))), 'examples', '*.py'), '| grep -v E702')
def test_setup(self):
system(command % join(dirname(abspath(dirname(__file__))), 'setup.py'))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment