Skip to content

Commit

Permalink
Removed inheritance breaking clear-output option
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeal committed Jul 2, 2020
1 parent 2c1ee7f commit ec4eaab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions nbconvert/preprocessors/clearoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from traitlets import Set
from .base import Preprocessor


class ClearOutputPreprocessor(Preprocessor):
"""
Removes the output from all code cells in a notebook.
Expand Down
4 changes: 2 additions & 2 deletions nbconvert/preprocessors/tagremove.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# Distributed under the terms of the Modified BSD License.

from traitlets import Set, Unicode
from . import ClearOutputPreprocessor
from .base import Preprocessor


class TagRemovePreprocessor(ClearOutputPreprocessor):
class TagRemovePreprocessor(Preprocessor):
"""
Removes inputs, outputs, or cells from a notebook that
have tags that designate they are to be removed prior to exporting
Expand Down
15 changes: 15 additions & 0 deletions nbconvert/tests/test_nbconvertapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import io
import nbformat

from .base import TestsBase
from ..postprocessors import PostProcessorBase
Expand Down Expand Up @@ -90,6 +91,20 @@ def test_explicit(self):
assert not os.path.isfile('notebook1.py')
assert os.path.isfile('notebook2.py')

def test_clear_output(self):
"""
Can we clear outputs?
"""
with self.create_temp_cwd(['notebook*.ipynb']) as td:
self.nbconvert('--clear-output notebook1')
assert os.path.isfile('notebook1.ipynb')
with open('notebook1.ipynb', encoding='utf8') as f:
nb = nbformat.read(f, 4)
for cell in nb.cells:
# Skip markdown cells
if 'outputs' in cell:
assert cell.outputs == []

def test_absolute_template_file(self):
"""--template-file '/path/to/template.tpl'"""
with self.create_temp_cwd(['notebook*.ipynb']), tempdir.TemporaryDirectory() as td:
Expand Down

0 comments on commit ec4eaab

Please sign in to comment.