Skip to content

Commit acaec03

Browse files
committed
Fix pep8 and pylint errors
1 parent 4ca8958 commit acaec03

File tree

8 files changed

+65
-34
lines changed

8 files changed

+65
-34
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test:
1212
rm -rf out
1313
python -B setup.py test
1414
pip install pep8 pylint
15-
pep8 sphinx_tabs/tabs.py
16-
pylint --rcfile=pylint.cfg sphinx_tabs/tabs.py
15+
find sphinx_tabs -name "*.py" -print0 | xargs -0 pep8
16+
pylint --rcfile=pylint.cfg sphinx_tabs
1717

1818
docs:
1919
rm -rf docs

pylint.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
[BASIC]
2+
extension-pkg-whitelist=lxml
3+
4+
[MESSAGES CONTROL]
5+
disable=missing-docstring,similarities,fixme
6+
17
[REPORTS]
28
reports=no

sphinx_tabs/test/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

sphinx_tabs/test/test_basic.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import unittest
22
import pkg_resources
3-
from sphinx_testing import with_app, path
3+
from sphinx_testing import with_app
44
from .testcase import TestCase
55

66

77
class BasicTest(TestCase):
8-
@with_app(buildername='html', srcdir=pkg_resources.resource_filename(__name__, 'basic'))
9-
def test_build_html(self, app, status, warning):
8+
@with_app(
9+
buildername='html',
10+
srcdir=pkg_resources.resource_filename(__name__, 'basic'))
11+
def test_build_html(
12+
self, app, status, warning): # pylint: disable=unused-argument
1013
app.builder.build_all()
1114
actual = self.get_result(app, 'index')
1215
expected = self.get_expectation('basic', 'index')

sphinx_tabs/test/test_conditionalassets.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import unittest
22
import pkg_resources
3-
from sphinx_testing import with_app, path
3+
from sphinx_testing import with_app
44
from .testcase import TestCase
55

66

77
class ConditionalAssetsTest(TestCase):
8-
@with_app(buildername='html', srcdir=pkg_resources.resource_filename(__name__, 'conditionalassets'))
9-
def test_build_html(self, app, status, warning):
8+
@with_app(
9+
buildername='html',
10+
srcdir=pkg_resources.resource_filename(__name__, 'conditionalassets'))
11+
def test_build_html(
12+
self, app, status, warning): # pylint: disable=unused-argument
1013
app.builder.build_all()
1114
for filename in ('index', 'other', 'other2'):
1215
actual = self.get_result(app, filename)

sphinx_tabs/test/test_nestedmarkup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55

66

77
class NestedMarkupTest(TestCase):
8-
@with_app(buildername='html', srcdir=pkg_resources.resource_filename(__name__, 'nestedmarkup'))
9-
def test_build_html(self, app, status, warning):
8+
@with_app(
9+
buildername='html',
10+
srcdir=pkg_resources.resource_filename(__name__, 'nestedmarkup'))
11+
def test_build_html(
12+
self, app, status, warning): # pylint: disable=unused-argument
1013
app.builder.build_all()
1114
actual = self.get_result(app, 'index')
1215
expected = self.get_expectation('nestedmarkup', 'index')
13-
self.assertHasTabsAssets(actual, filter_scripts=lambda x: 'mathjax' not in x)
16+
self.assertHasTabsAssets(
17+
actual, filter_scripts=lambda x: 'mathjax' not in x)
1418
self.assertXMLEqual(expected, actual)
1519

1620

sphinx_tabs/test/test_notabs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66

77
class NoTabsTest(TestCase):
8-
@with_app(buildername='html', srcdir=pkg_resources.resource_filename(__name__, 'notabs'))
9-
def test_build_html(self, app, status, warning):
8+
@with_app(
9+
buildername='html',
10+
srcdir=pkg_resources.resource_filename(__name__, 'notabs'))
11+
def test_build_html(
12+
self, app, status, warning): # pylint: disable=unused-argument
1013
app.builder.build_all()
1114
actual = self.get_result(app, 'index')
1215
expected = self.get_expectation('notabs', 'index')
13-
#self.assertDoesNotHaveTabsAssets(actual)
16+
self.assertDoesNotHaveTabsAssets(actual)
1417
self.assertXMLEqual(expected, actual)
1518

1619

sphinx_tabs/test/testcase.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# pylint: disable=import-error,no-name-in-module
2+
from distutils.version import StrictVersion
3+
# pylint: enable=import-error,no-name-in-module
4+
from io import StringIO
15
import unittest
26
import re
3-
from io import StringIO
4-
from lxml import objectify, etree
5-
from sphinx_testing import path
67
import pkg_resources
7-
from distutils.version import StrictVersion
8+
from lxml import etree
89
from sphinx import __version__ as __sphinx_version__
910
from sphinx.builders.html import StandaloneHTMLBuilder
1011

@@ -15,15 +16,15 @@ def _parse(xml):
1516
return etree.parse(StringIO(xml), parser)
1617

1718

18-
def _strip_xmlns(x):
19-
return x.replace(' xmlns="http://www.w3.org/1999/xhtml"', '')
19+
def _strip_xmlns(xml):
20+
return xml.replace(' xmlns="http://www.w3.org/1999/xhtml"', '')
2021

2122

2223
def get_scripts(xml):
2324
tree = _parse(xml)
2425
scripts = tree.findall('.//{*}script')
25-
return [x.replace('_static/', '')
26-
for x in filter(lambda x: x is not None, [x.get('src') for x in scripts])]
26+
scripts = [x.get('src') for x in scripts]
27+
return [x.replace('_static/', '') for x in scripts if x is not None]
2728

2829

2930
def get_stylesheets(xml):
@@ -40,32 +41,41 @@ def get_body(xml):
4041

4142
def normalize_xml(xml):
4243
content = re.sub(r'>\s+<', '><', xml)
43-
content = etree.tostring(_parse(content), pretty_print=True).decode('utf-8')
44+
content = etree.tostring(
45+
_parse(content), pretty_print=True).decode('utf-8')
4446
return content
4547

4648

4749
class TestCase(unittest.TestCase):
48-
def tearDown(self):
50+
def tearDown(self): # pylint: disable=invalid-name
4951
# Reset script and css files after test
50-
StandaloneHTMLBuilder.script_files = StandaloneHTMLBuilder.script_files[:3]
52+
StandaloneHTMLBuilder.script_files = \
53+
StandaloneHTMLBuilder.script_files[:3]
5154
if StrictVersion(__sphinx_version__) > StrictVersion('1.6.0'):
55+
# pylint: disable=no-name-in-module
5256
from sphinx.builders.html import CSSContainer
5357
StandaloneHTMLBuilder.css_files = CSSContainer()
58+
# pylint: enable=no-name-in-module
5459
else:
5560
StandaloneHTMLBuilder.css_files = []
5661

57-
def get_result(self, app, filename):
62+
@staticmethod
63+
def get_result(app, filename):
5864
return (app.outdir / (filename+'.html')).read_text(encoding='utf-8')
5965

60-
def get_expectation(self, dirname, filename):
61-
return pkg_resources.resource_string(__name__, '%s/%s.html' % (dirname, filename)).decode('utf-8')
66+
@staticmethod
67+
def get_expectation(dirname, filename):
68+
return pkg_resources.resource_string(
69+
__name__, '%s/%s.html' % (dirname, filename)).decode('utf-8')
6270

63-
def assertXMLEqual(self, expected, actual):
71+
def assertXMLEqual( # pylint: disable=invalid-name
72+
self, expected, actual):
6473
expected = normalize_xml(expected)
6574
actual = normalize_xml(get_body(actual))
6675
self.assertEqual(expected, actual)
6776

68-
def assertHasTabsAssets(self, xml, filter_scripts=None):
77+
def assertHasTabsAssets( # pylint: disable=invalid-name
78+
self, xml, filter_scripts=None):
6979
stylesheets = get_stylesheets(xml)
7080
scripts = get_scripts(xml)
7181
if filter_scripts is not None:
@@ -87,7 +97,8 @@ def assertHasTabsAssets(self, xml, filter_scripts=None):
8797
'sphinx_tabs/semantic-ui-2.2.10/tab.min.js'
8898
])
8999

90-
def assertDoesNotHaveTabsAssets(self, xml):
100+
def assertDoesNotHaveTabsAssets( # pylint: disable=invalid-name
101+
self, xml):
91102
stylesheets = get_stylesheets(xml)
92103
scripts = get_scripts(xml)
93104
self.assertEqual(stylesheets, [
@@ -101,10 +112,12 @@ def assertDoesNotHaveTabsAssets(self, xml):
101112
'doctools.js'
102113
])
103114

104-
def assertStylesheetsEqual(self, expected, xml):
115+
def assertStylesheetsEqual( # pylint: disable=invalid-name
116+
self, expected, xml):
105117
actual = get_stylesheets(xml)
106118
self.assertEqual(expected, actual)
107119

108-
def assertScriptsEqual(self, expected, xml):
120+
def assertScriptsEqual( # pylint: disable=invalid-name
121+
self, expected, xml):
109122
actual = get_scripts(xml)
110123
self.assertEqual(expected, actual)

0 commit comments

Comments
 (0)