summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <sigmavirus24@users.noreply.github.com>2016-05-26 11:08:05 -0500
committerIan Cordasco <sigmavirus24@users.noreply.github.com>2016-05-26 11:08:05 -0500
commit990dc5a79e203204867870b7ec5048cdb37d7005 (patch)
tree4757cf8aaa07f81780a91cc38028caf43713f40c
parentc98b72f4eb6e640200eadecb9d09acdd15772799 (diff)
parentccc7f14000d92e8dc08bbdf34b9fac3435425087 (diff)
downloadpep8-990dc5a79e203204867870b7ec5048cdb37d7005.tar.gz
Merge pull request #510 from PyCQA/package-pycodestyle
Package pycodestyle
-rw-r--r--.travis.yml6
-rw-r--r--Makefile6
-rw-r--r--docs/advanced.rst22
-rwxr-xr-xpycodestyle.py (renamed from pep8.py)28
-rw-r--r--setup.py11
-rw-r--r--testsuite/support.py4
-rw-r--r--testsuite/test_all.py16
-rw-r--r--testsuite/test_api.py145
-rw-r--r--testsuite/test_parser.py4
-rw-r--r--testsuite/test_shell.py26
-rw-r--r--testsuite/test_util.py20
-rw-r--r--tox.ini6
12 files changed, 158 insertions, 136 deletions
diff --git a/.travis.yml b/.travis.yml
index 3149cbd..ee069e8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,9 +14,9 @@ install:
- pip install -e .
- pip list
script:
- - python pep8.py --testsuite testsuite
- - python pep8.py --statistics pep8.py
- - python pep8.py --doctest
+ - python pycodestyle.py --testsuite testsuite
+ - python pycodestyle.py --statistics pycodestyle.py
+ - python pycodestyle.py --doctest
- python setup.py test
notifications:
diff --git a/Makefile b/Makefile
index 29b243d..366f580 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
test :
- python pep8.py --testsuite testsuite
+ python pycodestyle.py --testsuite testsuite
selftest :
- python pep8.py --statistics pep8.py
+ python pycodestyle.py --statistics pycodestyle.py
doctest :
- python pep8.py --doctest
+ python pycodestyle.py --doctest
unittest :
python -m testsuite.test_all
diff --git a/docs/advanced.rst b/docs/advanced.rst
index de3be69..4f72e6e 100644
--- a/docs/advanced.rst
+++ b/docs/advanced.rst
@@ -13,14 +13,14 @@ can be highly useful for automated testing of coding style conformance
in your project::
import unittest
- import pep8
+ import pycodestyle
class TestCodeFormat(unittest.TestCase):
def test_pep8_conformance(self):
"""Test that we conform to PEP8."""
- pep8style = pep8.StyleGuide(quiet=True)
+ pep8style = pycodestyle.StyleGuide(quiet=True)
result = pep8style.check_files(['file1.py', 'file2.py'])
self.assertEqual(result.total_errors, 0,
"Found code style errors (and warnings).")
@@ -30,9 +30,9 @@ since Nose suppresses stdout.
There's also a shortcut for checking a single file::
- import pep8
+ import pycodestyle
- fchecker = pep8.Checker('testsuite/E27.py', show_source=True)
+ fchecker = pycodestyle.Checker('testsuite/E27.py', show_source=True)
file_errors = fchecker.check_all()
print("Found %s errors (and warnings)" % file_errors)
@@ -46,13 +46,13 @@ You can configure automated ``pep8`` tests in a variety of ways.
For example, you can pass in a path to a configuration file that ``pep8``
should use::
- import pep8
+ import pycodestyle
- pep8style = pep8.StyleGuide(config_file='/path/to/tox.ini')
+ pep8style = pycodestyle.StyleGuide(config_file='/path/to/tox.ini')
You can also set specific options explicitly::
- pep8style = pep8.StyleGuide(ignore=['E501'])
+ pep8style = pycodestyle.StyleGuide(ignore=['E501'])
Skip file header
@@ -64,19 +64,19 @@ at the beginning and the end of a file. This use case is easy to implement
through a custom wrapper for the PEP 8 library::
#!python
- import pep8
+ import pycodestyle
LINES_SLICE = slice(14, -20)
- class PEP8(pep8.StyleGuide):
- """This subclass of pep8.StyleGuide will skip the first and last lines
+ class PEP8(pycodestyle.StyleGuide):
+ """This subclass of pycodestyle.StyleGuide will skip the first and last lines
of each file."""
def input_file(self, filename, lines=None, expected=None, line_offset=0):
if lines is None:
assert line_offset == 0
line_offset = LINES_SLICE.start or 0
- lines = pep8.readlines(filename)[LINES_SLICE]
+ lines = pycodestyle.readlines(filename)[LINES_SLICE]
return super(PEP8, self).input_file(
filename, lines=lines, expected=expected, line_offset=line_offset)
diff --git a/pep8.py b/pycodestyle.py
index 207af15..5e90dcf 100755
--- a/pep8.py
+++ b/pycodestyle.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-# pep8.py - Check Python source code formatting, according to PEP 8
+# pycodestyle.py - Check Python source code formatting, according to PEP 8
+#
# Copyright (C) 2006-2009 Johann C. Rocholl <johann@rocholl.net>
# Copyright (C) 2009-2014 Florent Xicluna <florent.xicluna@gmail.com>
# Copyright (C) 2014-2016 Ian Lee <ianlee1521@gmail.com>
@@ -28,7 +29,7 @@ r"""
Check Python source code formatting, according to PEP 8.
For usage and a list of options, try this:
-$ python pep8.py -h
+$ python pycodestyle.py -h
This program and its regression test suite live here:
https://github.com/pycqa/pycodestyle
@@ -2158,14 +2159,14 @@ def _main():
except AttributeError:
pass # not supported on Windows
- pep8style = StyleGuide(parse_argv=True)
- options = pep8style.options
+ style_guide = StyleGuide(parse_argv=True)
+ options = style_guide.options
if options.doctest or options.testsuite:
from testsuite.support import run_tests
- report = run_tests(pep8style)
+ report = run_tests(style_guide)
else:
- report = pep8style.check_files()
+ report = style_guide.check_files()
if options.statistics:
report.print_statistics()
@@ -2181,5 +2182,20 @@ def _main():
sys.stderr.write(str(report.total_errors) + '\n')
sys.exit(1)
+
+def _main_pep8():
+ """Entrypoint for pep8 commandline tool.
+
+ Warn of deprecation and advise users to switch to pycodestyle.
+ """
+ print(
+ 'Deprecation Warning:\n'
+ 'pep8 has been renamed to pycodestyle and the use of the pep8 '
+ 'executable will be removed in a future release. Please use '
+ '`pycodestyle` instead.\n'
+ )
+ _main()
+
+
if __name__ == '__main__':
_main()
diff --git a/setup.py b/setup.py
index 29182c6..c0afd37 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup
def get_version():
- with open('pep8.py') as f:
+ with open('pycodestyle.py') as f:
for line in f:
if line.startswith('__version__'):
return eval(line.split('=')[-1])
@@ -19,16 +19,16 @@ def get_long_description():
setup(
- name='pep8',
+ name='pycodestyle',
version=get_version(),
description="Python style guide checker",
long_description=get_long_description(),
- keywords='pep8',
+ keywords='pycodestyle, pep8, PEP 8, PEP-8, PEP8',
author='Johann C. Rocholl',
author_email='johann@rocholl.net',
url='http://pep8.readthedocs.org/',
license='Expat license',
- py_modules=['pep8'],
+ py_modules=['pycodestyle'],
namespace_packages=[],
include_package_data=True,
zip_safe=False,
@@ -38,7 +38,8 @@ setup(
],
entry_points={
'console_scripts': [
- 'pep8 = pep8:_main',
+ 'pycodestyle = pycodestyle:_main',
+ 'pep8 = pycodestyle:_main_pep8',
],
},
classifiers=[
diff --git a/testsuite/support.py b/testsuite/support.py
index 6bc795d..003f181 100644
--- a/testsuite/support.py
+++ b/testsuite/support.py
@@ -3,7 +3,7 @@ import os.path
import re
import sys
-from pep8 import Checker, BaseReport, StandardReport, readlines
+from pycodestyle import Checker, BaseReport, StandardReport, readlines
SELFTEST_REGEX = re.compile(r'\b(Okay|[EW]\d{3}):\s(.*)')
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
@@ -119,7 +119,7 @@ def selftest(options):
print("%s: %s" % (code, source))
else:
count_failed += 1
- print("pep8.py: %s:" % error)
+ print("pycodestyle.py: %s:" % error)
for line in checker.lines:
print(line.rstrip())
return count_failed, count_all
diff --git a/testsuite/test_all.py b/testsuite/test_all.py
index bfb61d5..bd18943 100644
--- a/testsuite/test_all.py
+++ b/testsuite/test_all.py
@@ -4,24 +4,26 @@ import os.path
import sys
import unittest
-import pep8
+import pycodestyle
from testsuite.support import init_tests, selftest, ROOT_DIR
# Note: please only use a subset of unittest methods which were present
# in Python 2.5: assert(True|False|Equal|NotEqual|Raises)
-class Pep8TestCase(unittest.TestCase):
+class PycodestyleTestCase(unittest.TestCase):
"""Test the standard errors and warnings (E and W)."""
def setUp(self):
- self._style = pep8.StyleGuide(
+ self._style = pycodestyle.StyleGuide(
paths=[os.path.join(ROOT_DIR, 'testsuite')],
select='E,W', quiet=True)
def test_doctest(self):
import doctest
- fail_d, done_d = doctest.testmod(pep8, verbose=False, report=False)
+ fail_d, done_d = doctest.testmod(
+ pycodestyle, verbose=False, report=False
+ )
self.assertTrue(done_d, msg='tests not found')
self.assertFalse(fail_d, msg='%s failure(s)' % fail_d)
@@ -37,9 +39,9 @@ class Pep8TestCase(unittest.TestCase):
msg='%s failure(s)' % report.total_errors)
def test_own_dog_food(self):
- files = [pep8.__file__.rstrip('oc'), __file__.rstrip('oc'),
+ files = [pycodestyle.__file__.rstrip('oc'), __file__.rstrip('oc'),
os.path.join(ROOT_DIR, 'setup.py')]
- report = self._style.init_report(pep8.StandardReport)
+ report = self._style.init_report(pycodestyle.StandardReport)
report = self._style.check_files(files)
self.assertFalse(report.total_errors,
msg='Failures: %s' % report.messages)
@@ -49,7 +51,7 @@ def suite():
from testsuite import test_api, test_parser, test_shell, test_util
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Pep8TestCase))
+ suite.addTest(unittest.makeSuite(PycodestyleTestCase))
suite.addTest(unittest.makeSuite(test_api.APITestCase))
suite.addTest(unittest.makeSuite(test_parser.ParserTestCase))
suite.addTest(unittest.makeSuite(test_shell.ShellTestCase))
diff --git a/testsuite/test_api.py b/testsuite/test_api.py
index baafff7..6549a46 100644
--- a/testsuite/test_api.py
+++ b/testsuite/test_api.py
@@ -4,7 +4,7 @@ import shlex
import sys
import unittest
-import pep8
+import pycodestyle
from testsuite.support import ROOT_DIR, PseudoFile
E11 = os.path.join(ROOT_DIR, 'testsuite', 'E11.py')
@@ -25,17 +25,18 @@ class APITestCase(unittest.TestCase):
def setUp(self):
self._saved_stdout = sys.stdout
self._saved_stderr = sys.stderr
- self._saved_checks = pep8._checks
+ self._saved_checks = pycodestyle._checks
sys.stdout = PseudoFile()
sys.stderr = PseudoFile()
- pep8._checks = dict((k, dict((f, (vals[0][:], vals[1]))
- for (f, vals) in v.items()))
- for (k, v) in self._saved_checks.items())
+ pycodestyle._checks = dict(
+ (k, dict((f, (vals[0][:], vals[1])) for (f, vals) in v.items()))
+ for (k, v) in self._saved_checks.items()
+ )
def tearDown(self):
sys.stdout = self._saved_stdout
sys.stderr = self._saved_stderr
- pep8._checks = self._saved_checks
+ pycodestyle._checks = self._saved_checks
def reset(self):
del sys.stdout[:], sys.stderr[:]
@@ -44,14 +45,14 @@ class APITestCase(unittest.TestCase):
def check_dummy(physical_line, line_number):
if False:
yield
- pep8.register_check(check_dummy, ['Z001'])
+ pycodestyle.register_check(check_dummy, ['Z001'])
- self.assertTrue(check_dummy in pep8._checks['physical_line'])
- codes, args = pep8._checks['physical_line'][check_dummy]
+ self.assertTrue(check_dummy in pycodestyle._checks['physical_line'])
+ codes, args = pycodestyle._checks['physical_line'][check_dummy]
self.assertTrue('Z001' in codes)
self.assertEqual(args, ['physical_line', 'line_number'])
- options = pep8.StyleGuide().options
+ options = pycodestyle.StyleGuide().options
self.assertTrue(any(func == check_dummy
for name, func, args in options.physical_checks))
@@ -59,32 +60,32 @@ class APITestCase(unittest.TestCase):
def check_dummy(logical_line, tokens):
if False:
yield
- pep8.register_check(check_dummy, ['Z401'])
+ pycodestyle.register_check(check_dummy, ['Z401'])
- self.assertTrue(check_dummy in pep8._checks['logical_line'])
- codes, args = pep8._checks['logical_line'][check_dummy]
+ self.assertTrue(check_dummy in pycodestyle._checks['logical_line'])
+ codes, args = pycodestyle._checks['logical_line'][check_dummy]
self.assertTrue('Z401' in codes)
self.assertEqual(args, ['logical_line', 'tokens'])
- pep8.register_check(check_dummy, [])
- pep8.register_check(check_dummy, ['Z402', 'Z403'])
- codes, args = pep8._checks['logical_line'][check_dummy]
+ pycodestyle.register_check(check_dummy, [])
+ pycodestyle.register_check(check_dummy, ['Z402', 'Z403'])
+ codes, args = pycodestyle._checks['logical_line'][check_dummy]
self.assertEqual(codes, ['Z401', 'Z402', 'Z403'])
self.assertEqual(args, ['logical_line', 'tokens'])
- options = pep8.StyleGuide().options
+ options = pycodestyle.StyleGuide().options
self.assertTrue(any(func == check_dummy
for name, func, args in options.logical_checks))
def test_register_ast_check(self):
- pep8.register_check(DummyChecker, ['Z701'])
+ pycodestyle.register_check(DummyChecker, ['Z701'])
- self.assertTrue(DummyChecker in pep8._checks['tree'])
- codes, args = pep8._checks['tree'][DummyChecker]
+ self.assertTrue(DummyChecker in pycodestyle._checks['tree'])
+ codes, args = pycodestyle._checks['tree'][DummyChecker]
self.assertTrue('Z701' in codes)
self.assertTrue(args is None)
- options = pep8.StyleGuide().options
+ options = pycodestyle.StyleGuide().options
self.assertTrue(any(cls == DummyChecker
for name, cls, args in options.ast_checks))
@@ -96,23 +97,23 @@ class APITestCase(unittest.TestCase):
def check_dummy(logical, tokens):
if False:
yield
- pep8.register_check(InvalidChecker, ['Z741'])
- pep8.register_check(check_dummy, ['Z441'])
+ pycodestyle.register_check(InvalidChecker, ['Z741'])
+ pycodestyle.register_check(check_dummy, ['Z441'])
- for checkers in pep8._checks.values():
+ for checkers in pycodestyle._checks.values():
self.assertTrue(DummyChecker not in checkers)
self.assertTrue(check_dummy not in checkers)
- self.assertRaises(TypeError, pep8.register_check)
+ self.assertRaises(TypeError, pycodestyle.register_check)
def test_styleguide(self):
- report = pep8.StyleGuide().check_files()
+ report = pycodestyle.StyleGuide().check_files()
self.assertEqual(report.total_errors, 0)
self.assertFalse(sys.stdout)
self.assertFalse(sys.stderr)
self.reset()
- report = pep8.StyleGuide().check_files(['missing-file'])
+ report = pycodestyle.StyleGuide().check_files(['missing-file'])
stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(len(stdout), report.total_errors)
self.assertEqual(report.total_errors, 1)
@@ -121,7 +122,7 @@ class APITestCase(unittest.TestCase):
self.assertFalse(sys.stderr)
self.reset()
- report = pep8.StyleGuide().check_files([E11])
+ report = pycodestyle.StyleGuide().check_files([E11])
stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(len(stdout), report.total_errors)
self.assertEqual(report.total_errors, 17)
@@ -129,7 +130,7 @@ class APITestCase(unittest.TestCase):
self.reset()
# Passing the paths in the constructor gives same result
- report = pep8.StyleGuide(paths=[E11]).check_files()
+ report = pycodestyle.StyleGuide(paths=[E11]).check_files()
stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(len(stdout), report.total_errors)
self.assertEqual(report.total_errors, 17)
@@ -137,11 +138,11 @@ class APITestCase(unittest.TestCase):
self.reset()
def test_styleguide_options(self):
- # Instantiate a simple checker
- pep8style = pep8.StyleGuide(paths=[E11])
+ # Instanciate a simple checker
+ pep8style = pycodestyle.StyleGuide(paths=[E11])
# Check style's attributes
- self.assertEqual(pep8style.checker_class, pep8.Checker)
+ self.assertEqual(pep8style.checker_class, pycodestyle.Checker)
self.assertEqual(pep8style.paths, [E11])
self.assertEqual(pep8style.runner, pep8style.input_file)
self.assertEqual(pep8style.options.ignore_code, pep8style.ignore_code)
@@ -173,7 +174,7 @@ class APITestCase(unittest.TestCase):
_saved_argv = sys.argv
sys.argv = shlex.split('pep8 %s /dev/null' % argstring)
try:
- return pep8.StyleGuide(parse_argv=True)
+ return pycodestyle.StyleGuide(parse_argv=True)
finally:
sys.argv = _saved_argv
@@ -208,22 +209,22 @@ class APITestCase(unittest.TestCase):
self.assertEqual(options.select, ('E24',))
self.assertEqual(options.ignore, ('',))
- pep8style = pep8.StyleGuide(paths=[E11])
+ pep8style = pycodestyle.StyleGuide(paths=[E11])
self.assertFalse(pep8style.ignore_code('E112'))
self.assertFalse(pep8style.ignore_code('W191'))
self.assertTrue(pep8style.ignore_code('E241'))
- pep8style = pep8.StyleGuide(select='E', paths=[E11])
+ pep8style = pycodestyle.StyleGuide(select='E', paths=[E11])
self.assertFalse(pep8style.ignore_code('E112'))
self.assertTrue(pep8style.ignore_code('W191'))
self.assertFalse(pep8style.ignore_code('E241'))
- pep8style = pep8.StyleGuide(select='W', paths=[E11])
+ pep8style = pycodestyle.StyleGuide(select='W', paths=[E11])
self.assertTrue(pep8style.ignore_code('E112'))
self.assertFalse(pep8style.ignore_code('W191'))
self.assertTrue(pep8style.ignore_code('E241'))
- pep8style = pep8.StyleGuide(select=('F401',), paths=[E11])
+ pep8style = pycodestyle.StyleGuide(select=('F401',), paths=[E11])
self.assertEqual(pep8style.options.select, ('F401',))
self.assertEqual(pep8style.options.ignore, ('',))
self.assertFalse(pep8style.ignore_code('F'))
@@ -231,7 +232,7 @@ class APITestCase(unittest.TestCase):
self.assertTrue(pep8style.ignore_code('F402'))
def test_styleguide_excluded(self):
- pep8style = pep8.StyleGuide(paths=[E11])
+ pep8style = pycodestyle.StyleGuide(paths=[E11])
self.assertFalse(pep8style.excluded('./foo/bar'))
self.assertFalse(pep8style.excluded('./foo/bar/main.py'))
@@ -248,7 +249,7 @@ class APITestCase(unittest.TestCase):
self.assertFalse(pep8style.excluded('./CVS/subdir'))
def test_styleguide_checks(self):
- pep8style = pep8.StyleGuide(paths=[E11])
+ pep8style = pycodestyle.StyleGuide(paths=[E11])
# Default lists of checkers
self.assertTrue(len(pep8style.options.physical_checks) > 4)
@@ -264,49 +265,51 @@ class APITestCase(unittest.TestCase):
self.assertEqual(args[0], 'logical_line')
# Do run E11 checks
- options = pep8.StyleGuide().options
- self.assertTrue(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide().options
+ self.assertTrue(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
- options = pep8.StyleGuide(select=['E']).options
- self.assertTrue(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(select=['E']).options
+ self.assertTrue(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
- options = pep8.StyleGuide(ignore=['W']).options
- self.assertTrue(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(ignore=['W']).options
+ self.assertTrue(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
- options = pep8.StyleGuide(ignore=['E12']).options
- self.assertTrue(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(ignore=['E12']).options
+ self.assertTrue(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
# Do not run E11 checks
- options = pep8.StyleGuide(select=['W']).options
- self.assertFalse(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(select=['W']).options
+ self.assertFalse(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
- options = pep8.StyleGuide(ignore=['E']).options
- self.assertFalse(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(ignore=['E']).options
+ self.assertFalse(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
- options = pep8.StyleGuide(ignore=['E11']).options
- self.assertFalse(any(func == pep8.indentation
+ options = pycodestyle.StyleGuide(ignore=['E11']).options
+ self.assertFalse(any(func == pycodestyle.indentation
for name, func, args in options.logical_checks))
def test_styleguide_init_report(self):
- pep8style = pep8.StyleGuide(paths=[E11])
+ style = pycodestyle.StyleGuide(paths=[E11])
+
+ standard_report = pycodestyle.StandardReport
- self.assertEqual(pep8style.options.reporter, pep8.StandardReport)
- self.assertEqual(type(pep8style.options.report), pep8.StandardReport)
+ self.assertEqual(style.options.reporter, standard_report)
+ self.assertEqual(type(style.options.report), standard_report)
- class MinorityReport(pep8.BaseReport):
+ class MinorityReport(pycodestyle.BaseReport):
pass
- report = pep8style.init_report(MinorityReport)
- self.assertEqual(pep8style.options.report, report)
+ report = style.init_report(MinorityReport)
+ self.assertEqual(style.options.report, report)
self.assertEqual(type(report), MinorityReport)
- pep8style = pep8.StyleGuide(paths=[E11], reporter=MinorityReport)
- self.assertEqual(type(pep8style.options.report), MinorityReport)
- self.assertEqual(pep8style.options.reporter, MinorityReport)
+ style = pycodestyle.StyleGuide(paths=[E11], reporter=MinorityReport)
+ self.assertEqual(type(style.options.report), MinorityReport)
+ self.assertEqual(style.options.reporter, MinorityReport)
def test_styleguide_check_files(self):
- pep8style = pep8.StyleGuide(paths=[E11])
+ pep8style = pycodestyle.StyleGuide(paths=[E11])
report = pep8style.check_files()
self.assertTrue(report.total_errors)
@@ -317,12 +320,12 @@ class APITestCase(unittest.TestCase):
def test_check_unicode(self):
# Do not crash if lines are Unicode (Python 2.x)
- pep8.register_check(DummyChecker, ['Z701'])
+ pycodestyle.register_check(DummyChecker, ['Z701'])
source = '#\n'
if hasattr(source, 'decode'):
source = source.decode('ascii')
- pep8style = pep8.StyleGuide()
+ pep8style = pycodestyle.StyleGuide()
count_errors = pep8style.input_file('stdin', lines=[source])
self.assertFalse(sys.stdout)
@@ -330,9 +333,9 @@ class APITestCase(unittest.TestCase):
self.assertEqual(count_errors, 0)
def test_check_nullbytes(self):
- pep8.register_check(DummyChecker, ['Z701'])
+ pycodestyle.register_check(DummyChecker, ['Z701'])
- pep8style = pep8.StyleGuide()
+ pep8style = pycodestyle.StyleGuide()
count_errors = pep8style.input_file('stdin', lines=['\x00\n'])
stdout = sys.stdout.getvalue()
@@ -351,13 +354,13 @@ class APITestCase(unittest.TestCase):
self.assertEqual(count_errors, 1)
def test_styleguide_unmatched_triple_quotes(self):
- pep8.register_check(DummyChecker, ['Z701'])
+ pycodestyle.register_check(DummyChecker, ['Z701'])
lines = [
'def foo():\n',
' """test docstring""\'\n',
]
- pep8style = pep8.StyleGuide()
+ pep8style = pycodestyle.StyleGuide()
pep8style.input_file('stdin', lines=lines)
stdout = sys.stdout.getvalue()
@@ -365,7 +368,7 @@ class APITestCase(unittest.TestCase):
self.assertTrue(expected in stdout)
def test_styleguide_continuation_line_outdented(self):
- pep8.register_check(DummyChecker, ['Z701'])
+ pycodestyle.register_check(DummyChecker, ['Z701'])
lines = [
'def foo():\n',
' pass\n',
@@ -376,7 +379,7 @@ class APITestCase(unittest.TestCase):
' pass\n',
]
- pep8style = pep8.StyleGuide()
+ pep8style = pycodestyle.StyleGuide()
count_errors = pep8style.input_file('stdin', lines=lines)
self.assertEqual(count_errors, 2)
stdout = sys.stdout.getvalue()
diff --git a/testsuite/test_parser.py b/testsuite/test_parser.py
index 1d9e1ac..26a45fc 100644
--- a/testsuite/test_parser.py
+++ b/testsuite/test_parser.py
@@ -2,14 +2,14 @@ import os
import tempfile
import unittest
-import pep8
+import pycodestyle
def _process_file(contents):
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(contents)
- options, args = pep8.process_options(config_file=f.name)
+ options, args = pycodestyle.process_options(config_file=f.name)
os.remove(f.name)
return options, args
diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py
index e536852..760c228 100644
--- a/testsuite/test_shell.py
+++ b/testsuite/test_shell.py
@@ -3,7 +3,7 @@ import os.path
import sys
import unittest
-import pep8
+import pycodestyle
from testsuite.support import ROOT_DIR, PseudoFile
@@ -14,9 +14,9 @@ class ShellTestCase(unittest.TestCase):
self._saved_argv = sys.argv
self._saved_stdout = sys.stdout
self._saved_stderr = sys.stderr
- self._saved_pconfig = pep8.PROJECT_CONFIG
- self._saved_cpread = pep8.RawConfigParser._read
- self._saved_stdin_get_value = pep8.stdin_get_value
+ self._saved_pconfig = pycodestyle.PROJECT_CONFIG
+ self._saved_cpread = pycodestyle.RawConfigParser._read
+ self._saved_stdin_get_value = pycodestyle.stdin_get_value
self._config_filenames = []
self.stdin = ''
sys.argv = ['pep8']
@@ -25,16 +25,16 @@ class ShellTestCase(unittest.TestCase):
def fake_config_parser_read(cp, fp, filename):
self._config_filenames.append(filename)
- pep8.RawConfigParser._read = fake_config_parser_read
- pep8.stdin_get_value = self.stdin_get_value
+ pycodestyle.RawConfigParser._read = fake_config_parser_read
+ pycodestyle.stdin_get_value = self.stdin_get_value
def tearDown(self):
sys.argv = self._saved_argv
sys.stdout = self._saved_stdout
sys.stderr = self._saved_stderr
- pep8.PROJECT_CONFIG = self._saved_pconfig
- pep8.RawConfigParser._read = self._saved_cpread
- pep8.stdin_get_value = self._saved_stdin_get_value
+ pycodestyle.PROJECT_CONFIG = self._saved_pconfig
+ pycodestyle.RawConfigParser._read = self._saved_cpread
+ pycodestyle.stdin_get_value = self._saved_stdin_get_value
def stdin_get_value(self):
return self.stdin
@@ -43,7 +43,7 @@ class ShellTestCase(unittest.TestCase):
del sys.stdout[:], sys.stderr[:]
sys.argv[1:] = args
try:
- pep8._main()
+ pycodestyle._main()
errorcode = None
except SystemExit:
errorcode = sys.exc_info()[1].code
@@ -88,7 +88,7 @@ class ShellTestCase(unittest.TestCase):
self.assertTrue('setup.cfg' in config_filenames)
def test_check_stdin(self):
- pep8.PROJECT_CONFIG = ()
+ pycodestyle.PROJECT_CONFIG = ()
stdout, stderr, errcode = self.pep8('-')
self.assertFalse(errcode)
self.assertFalse(stderr)
@@ -111,7 +111,7 @@ class ShellTestCase(unittest.TestCase):
def test_check_noarg(self):
# issue #170: do not read stdin by default
- pep8.PROJECT_CONFIG = ()
+ pycodestyle.PROJECT_CONFIG = ()
stdout, stderr, errcode = self.pep8()
self.assertEqual(errcode, 2)
self.assertEqual(stderr.splitlines(),
@@ -120,7 +120,7 @@ class ShellTestCase(unittest.TestCase):
self.assertFalse(self._config_filenames)
def test_check_diff(self):
- pep8.PROJECT_CONFIG = ()
+ pycodestyle.PROJECT_CONFIG = ()
diff_lines = [
"--- testsuite/E11.py 2006-06-01 08:49:50 +0500",
"+++ testsuite/E11.py 2008-04-06 17:36:29 +0500",
diff --git a/testsuite/test_util.py b/testsuite/test_util.py
index 11395cc..8eaba7e 100644
--- a/testsuite/test_util.py
+++ b/testsuite/test_util.py
@@ -3,21 +3,21 @@
import os
import unittest
-import pep8
+from pycodestyle import normalize_paths
class UtilTestCase(unittest.TestCase):
def test_normalize_paths(self):
cwd = os.getcwd()
- self.assertEqual(pep8.normalize_paths(''), [])
- self.assertEqual(pep8.normalize_paths([]), [])
- self.assertEqual(pep8.normalize_paths(None), [])
- self.assertEqual(pep8.normalize_paths(['foo']), ['foo'])
- self.assertEqual(pep8.normalize_paths('foo'), ['foo'])
- self.assertEqual(pep8.normalize_paths('foo,bar'), ['foo', 'bar'])
- self.assertEqual(pep8.normalize_paths('foo, bar '), ['foo', 'bar'])
- self.assertEqual(pep8.normalize_paths('/foo/bar,baz/../bat'),
+ self.assertEqual(normalize_paths(''), [])
+ self.assertEqual(normalize_paths([]), [])
+ self.assertEqual(normalize_paths(None), [])
+ self.assertEqual(normalize_paths(['foo']), ['foo'])
+ self.assertEqual(normalize_paths('foo'), ['foo'])
+ self.assertEqual(normalize_paths('foo,bar'), ['foo', 'bar'])
+ self.assertEqual(normalize_paths('foo, bar '), ['foo', 'bar'])
+ self.assertEqual(normalize_paths('/foo/bar,baz/../bat'),
['/foo/bar', cwd + '/bat'])
- self.assertEqual(pep8.normalize_paths(".pyc,\n build/*"),
+ self.assertEqual(normalize_paths(".pyc,\n build/*"),
['.pyc', cwd + '/build/*'])
diff --git a/tox.ini b/tox.ini
index 5661fbb..a4992e9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@ envlist = py26, py27, py32, py33, py34, py35, pypy, pypy3, jython
[testenv]
commands =
{envpython} setup.py install
- {envpython} pep8.py --testsuite testsuite
- {envpython} pep8.py --statistics pep8.py
- {envpython} pep8.py --doctest
+ {envpython} pycodestyle.py --testsuite testsuite
+ {envpython} pycodestyle.py --statistics pycodestyle.py
+ {envpython} pycodestyle.py --doctest
{envpython} -m testsuite.test_all