Skip to content

Commit ccc7f14

Browse files
committed
Updated tests and doc examples -> pycodestyle
1 parent 90d83aa commit ccc7f14

File tree

6 files changed

+119
-114
lines changed

6 files changed

+119
-114
lines changed

docs/advanced.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ can be highly useful for automated testing of coding style conformance
1313
in your project::
1414

1515
import unittest
16-
import pep8
16+
import pycodestyle
1717

1818

1919
class TestCodeFormat(unittest.TestCase):
2020

2121
def test_pep8_conformance(self):
2222
"""Test that we conform to PEP8."""
23-
pep8style = pep8.StyleGuide(quiet=True)
23+
pep8style = pycodestyle.StyleGuide(quiet=True)
2424
result = pep8style.check_files(['file1.py', 'file2.py'])
2525
self.assertEqual(result.total_errors, 0,
2626
"Found code style errors (and warnings).")
@@ -30,9 +30,9 @@ since Nose suppresses stdout.
3030

3131
There's also a shortcut for checking a single file::
3232

33-
import pep8
33+
import pycodestyle
3434

35-
fchecker = pep8.Checker('testsuite/E27.py', show_source=True)
35+
fchecker = pycodestyle.Checker('testsuite/E27.py', show_source=True)
3636
file_errors = fchecker.check_all()
3737

3838
print("Found %s errors (and warnings)" % file_errors)
@@ -46,13 +46,13 @@ You can configure automated ``pep8`` tests in a variety of ways.
4646
For example, you can pass in a path to a configuration file that ``pep8``
4747
should use::
4848

49-
import pep8
49+
import pycodestyle
5050

51-
pep8style = pep8.StyleGuide(config_file='/path/to/tox.ini')
51+
pep8style = pycodestyle.StyleGuide(config_file='/path/to/tox.ini')
5252

5353
You can also set specific options explicitly::
5454

55-
pep8style = pep8.StyleGuide(ignore=['E501'])
55+
pep8style = pycodestyle.StyleGuide(ignore=['E501'])
5656

5757

5858
Skip file header
@@ -64,19 +64,19 @@ at the beginning and the end of a file. This use case is easy to implement
6464
through a custom wrapper for the PEP 8 library::
6565

6666
#!python
67-
import pep8
67+
import pycodestyle
6868

6969
LINES_SLICE = slice(14, -20)
7070

71-
class PEP8(pep8.StyleGuide):
72-
"""This subclass of pep8.StyleGuide will skip the first and last lines
71+
class PEP8(pycodestyle.StyleGuide):
72+
"""This subclass of pycodestyle.StyleGuide will skip the first and last lines
7373
of each file."""
7474

7575
def input_file(self, filename, lines=None, expected=None, line_offset=0):
7676
if lines is None:
7777
assert line_offset == 0
7878
line_offset = LINES_SLICE.start or 0
79-
lines = pep8.readlines(filename)[LINES_SLICE]
79+
lines = pycodestyle.readlines(filename)[LINES_SLICE]
8080
return super(PEP8, self).input_file(
8181
filename, lines=lines, expected=expected, line_offset=line_offset)
8282

testsuite/test_all.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@
44
import sys
55
import unittest
66

7-
import pep8
7+
import pycodestyle
88
from testsuite.support import init_tests, selftest, ROOT_DIR
99

1010
# Note: please only use a subset of unittest methods which were present
1111
# in Python 2.5: assert(True|False|Equal|NotEqual|Raises)
1212

1313

14-
class Pep8TestCase(unittest.TestCase):
14+
class PycodestyleTestCase(unittest.TestCase):
1515
"""Test the standard errors and warnings (E and W)."""
1616

1717
def setUp(self):
18-
self._style = pep8.StyleGuide(
18+
self._style = pycodestyle.StyleGuide(
1919
paths=[os.path.join(ROOT_DIR, 'testsuite')],
2020
select='E,W', quiet=True)
2121

2222
def test_doctest(self):
2323
import doctest
24-
fail_d, done_d = doctest.testmod(pep8, verbose=False, report=False)
24+
fail_d, done_d = doctest.testmod(
25+
pycodestyle, verbose=False, report=False
26+
)
2527
self.assertTrue(done_d, msg='tests not found')
2628
self.assertFalse(fail_d, msg='%s failure(s)' % fail_d)
2729

@@ -37,9 +39,9 @@ def test_checkers_testsuite(self):
3739
msg='%s failure(s)' % report.total_errors)
3840

3941
def test_own_dog_food(self):
40-
files = [pep8.__file__.rstrip('oc'), __file__.rstrip('oc'),
42+
files = [pycodestyle.__file__.rstrip('oc'), __file__.rstrip('oc'),
4143
os.path.join(ROOT_DIR, 'setup.py')]
42-
report = self._style.init_report(pep8.StandardReport)
44+
report = self._style.init_report(pycodestyle.StandardReport)
4345
report = self._style.check_files(files)
4446
self.assertFalse(report.total_errors,
4547
msg='Failures: %s' % report.messages)
@@ -49,7 +51,7 @@ def suite():
4951
from testsuite import test_api, test_parser, test_shell, test_util
5052

5153
suite = unittest.TestSuite()
52-
suite.addTest(unittest.makeSuite(Pep8TestCase))
54+
suite.addTest(unittest.makeSuite(PycodestyleTestCase))
5355
suite.addTest(unittest.makeSuite(test_api.APITestCase))
5456
suite.addTest(unittest.makeSuite(test_parser.ParserTestCase))
5557
suite.addTest(unittest.makeSuite(test_shell.ShellTestCase))

0 commit comments

Comments
 (0)