This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix an issue with travis and appveyor
- Loading branch information
Showing
4 changed files
with
222 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# example with comments" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This markdown contains a comment.\n", | ||
"\n", | ||
"[//]: # (RST: .. index:: comment, notebook, rst)\n", | ||
"\n", | ||
"It looks like this:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# [//]: # (RST: .. index:: comment, notebook, rst)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import pyquickhelper" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.4.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
74 changes: 74 additions & 0 deletions
74
_unittests/ut_helpgen/notebooks_comment/example_with_comments.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# example with comments" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This markdown contains a comment.\n", | ||
"\n", | ||
"[//]: # (RST: .. index:: comment, notebook, rst)\n", | ||
"\n", | ||
"It looks like this:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# [//]: # (RST: .. index:: comment, notebook, rst)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import pyquickhelper" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.4.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
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,73 @@ | ||
""" | ||
@brief test log(time=5s) | ||
@author Xavier Dupre | ||
""" | ||
|
||
import sys | ||
import os | ||
import unittest | ||
import re | ||
import warnings | ||
|
||
try: | ||
import src | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
".."))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import src | ||
|
||
from src.pyquickhelper import fLOG, process_notebooks, is_travis_or_appveyor | ||
|
||
if sys.version_info[0] == 2: | ||
from codecs import open | ||
|
||
|
||
class TestNoteBooksComment(unittest.TestCase): | ||
|
||
def test_notebook_comment(self): | ||
fLOG( | ||
__file__, | ||
self._testMethodName, | ||
OutputPrint=__name__ == "__main__") | ||
path = os.path.abspath(os.path.split(__file__)[0]) | ||
fold = os.path.normpath(os.path.join(path, "notebooks_comment")) | ||
nbs = [os.path.join(fold, _) | ||
for _ in os.listdir(fold) if ".ipynb" in _] | ||
formats = ["rst", ] | ||
|
||
temp = os.path.join(path, "temp_nb_comment") | ||
if not os.path.exists(temp): | ||
os.mkdir(temp) | ||
for file in os.listdir(temp): | ||
os.remove(os.path.join(temp, file)) | ||
|
||
if is_travis_or_appveyor() is not None: | ||
warnings.warn( | ||
"travis, appveyor, unable to test TestNoteBooksBugRst.test_notebook_rst") | ||
return | ||
|
||
res = process_notebooks(nbs, temp, temp, formats=formats) | ||
fLOG("*****", len(res)) | ||
for _ in res: | ||
fLOG(_) | ||
assert os.path.exists(_[0]) | ||
|
||
with open(os.path.join(temp, "example_with_comments.rst"), "r", encoding="utf8") as f: | ||
lines = f.readlines() | ||
nb = 0 | ||
for line in lines: | ||
if line.startswith(".. index:: comment, notebook, rst"): | ||
nb += 1 | ||
# it should work if the module is able to deal with comments (not yet) | ||
# self.assertEqual(nb, 1) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |