def test_notebook(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") if sys.version_info[0] == 2: # does not work on Python 2 return path = os.path.abspath(os.path.split(__file__)[0]) fold = os.path.normpath(os.path.join(path, "notebooks2")) nbs = [os.path.join(fold, _) for _ in os.listdir(fold) if ".ipynb" in _] formats = ["present", "ipynb", "html", "python", "rst", "pdf", "docx"] temp = get_temp_folder(__file__, "temp_nb_bug2") if is_travis_or_appveyor() is not None: warnings.warn("travis, appveyor, unable to test TestNoteBooksBug.test_notebook") return nbs2 = [] for r in nbs: r2 = os.path.join(temp, os.path.split(r)[-1]) shutil.copy(r, r2) nbs2.append(r2) r = upgrade_notebook(r2) fLOG("change", r) res = process_notebooks(nbs2, temp, temp, formats=formats, exc=False) fLOG("*****", len(res)) for _ in res: fLOG(_) assert os.path.exists(_[0]) check = os.path.join(temp, "miparcours.tex") with open(check, "r", encoding="utf8") as f: content = f.read() assert "\\end{document}" in content
def test_convert_notebooks(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.abspath(os.path.dirname(__file__)) fold2 = os.path.normpath( os.path.join(fold, "..", "..", "_doc", "notebooks")) for nbf in explore_folder_iterfile(fold2, pattern=".*[.]ipynb"): t = upgrade_notebook(nbf) if t: fLOG("modified", nbf) fold2 = os.path.normpath(os.path.join(fold, "..", "..", "_unittests")) for nbf in explore_folder_iterfile(fold2, pattern=".*[.]ipynb"): t = upgrade_notebook(nbf) if t: fLOG("modified", nbf)