Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fix an issue with travis and appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Oct 28, 2015
1 parent 765419b commit d333ed5
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 1 deletion.
74 changes: 74 additions & 0 deletions _doc/notebooks/example_with_comments.ipynb
@@ -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
}
@@ -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
}
2 changes: 1 addition & 1 deletion _unittests/ut_helpgen/test_notebooks.py
Expand Up @@ -21,7 +21,7 @@
sys.path.append(path)
import src

from src.pyquickhelper.loghelper.flog import fLOG, run_cmd, is_travis_or_appveyor
from src.pyquickhelper import fLOG, run_cmd, is_travis_or_appveyor
from src.pyquickhelper.helpgen.sphinx_main import process_notebooks, add_notebook_page
from src.pyquickhelper.helpgen.process_notebooks import get_ipython_program
from src.pyquickhelper import get_temp_folder
Expand Down
73 changes: 73 additions & 0 deletions _unittests/ut_helpgen/test_notebooks_comment.py
@@ -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()

0 comments on commit d333ed5

Please sign in to comment.