Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ exclude_lines =
pragma: no cover
if __name__ == .__main__.:
def test_suite()

fail_under = 99
11 changes: 2 additions & 9 deletions src/sphinxcontrib/programoutput/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def run(self):


_Command = namedtuple(
'Command', 'command shell hide_standard_error working_directory')
'_Command', 'command shell hide_standard_error working_directory')


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

@staticmethod
def __normalize_command(command, shell): # pylint:disable=unused-private-member
# Returns either a native string, to a tuple.
if (bytes is str
and not isinstance(command, str)
and hasattr(command, 'encode')):
# Python 2, given a unicode string
command = command.encode(sys.getfilesystemencoding())
assert isinstance(command, str)

# Returns either a native string, or a tuple.
if not shell and isinstance(command, str):
command = shlex.split(command)

Expand Down
29 changes: 0 additions & 29 deletions src/sphinxcontrib/programoutput/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import shutil
import tempfile

from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst import roles
from sphinx.application import Sphinx
Expand Down Expand Up @@ -53,26 +52,6 @@ def __get__(self, inst, class_):
html_theme = 'default'
"""

def _find_duplicate_default_nodes():
from sphinx import addnodes # pylint:disable=import-outside-toplevel

class App(object):

def __init__(self):
self.nodes = set()

def add_node(self, node):
self.nodes.add(node.__name__)


app = App()
try:
addnodes.setup(app)
except AttributeError:
# Sphinx 1 doesn't have this
pass

return app.nodes

class AppMixin(object):

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

document_encoding = 'utf-8'

duplicate_nodes_to_remove = _find_duplicate_default_nodes()

def setUp(self):
# Avoid "WARNING: while setting up extension
# sphinxcontrib.programoutput: directive u'program-output' is
Expand All @@ -98,12 +75,6 @@ def setUp(self):
# Likewise for 'eq'
self.roles = roles._roles.copy()

# Avoid "node class 'toctree' is already registered, its visitors will be overridden"
# By default this class has *no* `visit_` methods
for node in self.duplicate_nodes_to_remove:
if hasattr(nodes.GenericNodeVisitor, 'visit_' + node):
delattr(nodes.GenericNodeVisitor, 'visit_' + node)

def tearDown(self):
directives._directives = self.directives
roles._roles = self.roles
Expand Down