-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7383 from minrk/test-script-python
tests for ScriptExporter
- Loading branch information
Showing
2 changed files
with
51 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Tests for ScriptExporter""" | ||
|
||
# Copyright (c) IPython Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import sys | ||
|
||
from IPython.nbformat import v4 | ||
from IPython.utils.py3compat import PY3 | ||
|
||
from .base import ExportersTestsBase | ||
from ..script import ScriptExporter | ||
|
||
|
||
class TestScriptExporter(ExportersTestsBase): | ||
"""Tests for ScriptExporter""" | ||
|
||
exporter_class = ScriptExporter | ||
|
||
def test_constructor(self): | ||
"""Construct ScriptExporter""" | ||
e = self.exporter_class() | ||
|
||
def test_export(self): | ||
"""ScriptExporter can export something""" | ||
(output, resources) = self.exporter_class().from_filename(self._get_notebook()) | ||
assert len(output) > 0 | ||
|
||
def test_export_python(self): | ||
"""delegate to custom exporter from language_info""" | ||
exporter = self.exporter_class() | ||
|
||
pynb = v4.new_notebook() | ||
(output, resources) = self.exporter_class().from_notebook_node(pynb) | ||
self.assertNotIn('# coding: utf-8', output) | ||
|
||
pynb.metadata.language_info = { | ||
'name': 'python', | ||
'mimetype': 'text/x-python', | ||
'nbconvert_exporter': 'python', | ||
} | ||
(output, resources) = self.exporter_class().from_notebook_node(pynb) | ||
self.assertIn('# coding: utf-8', output) | ||
|
||
|