Skip to content

Commit 657611b

Browse files
committed
Remove unused/unneeded legacy code, which gets our code coverage numbers up; enforce this.
1 parent 351bc84 commit 657611b

3 files changed

Lines changed: 4 additions & 38 deletions

File tree

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ exclude_lines =
88
pragma: no cover
99
if __name__ == .__main__.:
1010
def test_suite()
11+
12+
fail_under = 99

src/sphinxcontrib/programoutput/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def run(self):
167167

168168

169169
_Command = namedtuple(
170-
'Command', 'command shell hide_standard_error working_directory')
170+
'_Command', 'command shell hide_standard_error working_directory')
171171

172172

173173
class Command(_Command):
@@ -191,14 +191,7 @@ def __new__(cls, command, shell=False, hide_standard_error=False,
191191

192192
@staticmethod
193193
def __normalize_command(command, shell): # pylint:disable=unused-private-member
194-
# Returns either a native string, to a tuple.
195-
if (bytes is str
196-
and not isinstance(command, str)
197-
and hasattr(command, 'encode')):
198-
# Python 2, given a unicode string
199-
command = command.encode(sys.getfilesystemencoding())
200-
assert isinstance(command, str)
201-
194+
# Returns either a native string, or a tuple.
202195
if not shell and isinstance(command, str):
203196
command = shlex.split(command)
204197

src/sphinxcontrib/programoutput/tests/__init__.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import shutil
44
import tempfile
55

6-
from docutils import nodes
76
from docutils.parsers.rst import directives
87
from docutils.parsers.rst import roles
98
from sphinx.application import Sphinx
@@ -53,26 +52,6 @@ def __get__(self, inst, class_):
5352
html_theme = 'default'
5453
"""
5554

56-
def _find_duplicate_default_nodes():
57-
from sphinx import addnodes # pylint:disable=import-outside-toplevel
58-
59-
class App(object):
60-
61-
def __init__(self):
62-
self.nodes = set()
63-
64-
def add_node(self, node):
65-
self.nodes.add(node.__name__)
66-
67-
68-
app = App()
69-
try:
70-
addnodes.setup(app)
71-
except AttributeError:
72-
# Sphinx 1 doesn't have this
73-
pass
74-
75-
return app.nodes
7655

7756
class AppMixin(object):
7857

@@ -87,8 +66,6 @@ class AppMixin(object):
8766

8867
document_encoding = 'utf-8'
8968

90-
duplicate_nodes_to_remove = _find_duplicate_default_nodes()
91-
9269
def setUp(self):
9370
# Avoid "WARNING: while setting up extension
9471
# sphinxcontrib.programoutput: directive u'program-output' is
@@ -98,12 +75,6 @@ def setUp(self):
9875
# Likewise for 'eq'
9976
self.roles = roles._roles.copy()
10077

101-
# Avoid "node class 'toctree' is already registered, its visitors will be overridden"
102-
# By default this class has *no* `visit_` methods
103-
for node in self.duplicate_nodes_to_remove:
104-
if hasattr(nodes.GenericNodeVisitor, 'visit_' + node):
105-
delattr(nodes.GenericNodeVisitor, 'visit_' + node)
106-
10778
def tearDown(self):
10879
directives._directives = self.directives
10980
roles._roles = self.roles

0 commit comments

Comments
 (0)