-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
6 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
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,41 @@ | ||
# -*- coding: utf-8 -*- | ||
r""" | ||
Test the Sphinx-Gallery python to Jupyter notebook converter CLI | ||
================================================================ | ||
This test only the command line utility. The notebook converter is | ||
tested as part of the Sphinx-Gallery tests. | ||
""" | ||
|
||
# Author: Óscar Nájera | ||
# License: 3-clause BSD | ||
|
||
from __future__ import division, absolute_import, print_function | ||
import os | ||
from unittest import TestCase | ||
import sphx_glr_python_to_jupyter | ||
|
||
|
||
class CommandLineTest(TestCase): | ||
"""Test the Sphinx-Gallery python to Jupyter notebook converter CLI""" | ||
|
||
def test_with_empty_args(self): | ||
""" User passes no args, should fail with SystemExit """ | ||
with self.assertRaises(SystemExit): | ||
sphx_glr_python_to_jupyter.parser.parse_args([]) | ||
|
||
def test_missing_file(self): | ||
""" User passes non existing file, should fail with FileNotFoundError """ | ||
args = sphx_glr_python_to_jupyter.parser.parse_args(['nofile.py']) | ||
with self.assertRaises(FileNotFoundError): | ||
sphx_glr_python_to_jupyter.main(args) | ||
|
||
|
||
def test_file_is_generated(): | ||
"""User passes good python file. Check notebook file is created""" | ||
|
||
args = sphx_glr_python_to_jupyter.parser.parse_args( | ||
['examples/plot_quantum.py']) | ||
sphx_glr_python_to_jupyter.main(args) | ||
assert os.path.isfile('examples/plot_quantum.ipynb') | ||
os.remove('examples/plot_quantum.ipynb') |
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