diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf54e771..4f04d319 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,9 @@ exclude: > \.vscode/settings\.json| tests/commonmark/commonmark\.json| .*\.xml| - tests/.*\.txt + tests/.*\.txt| + tests/test_parser.py| + tests/test_text_based.py )$ repos: diff --git a/tests/test_parser.py b/tests/test_parser.py index 7f1860ac..3f74a565 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -6,7 +6,13 @@ def test_basic_run(sphinx_run, file_regression): sphinx_run.build() # print(sphinx_run.status()) assert sphinx_run.warnings() == "" - assert sphinx_run.app.env.metadata == {"basic_run": {"test_name": "notebook1"}} + assert sphinx_run.app.env.metadata == { + "basic_run": { + "test_name": "notebook1", + "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.6.1"}', + } + } file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml") filenames = { @@ -23,7 +29,18 @@ def test_complex_outputs(sphinx_run, file_regression): # print(sphinx_run.status()) assert sphinx_run.warnings() == "" assert sphinx_run.app.env.metadata == { - "complex_outputs": {"celltoolbar": "Edit Metadata", "hide_input": "False"} + "complex_outputs": { + "celltoolbar": "Edit Metadata", + "hide_input": "False", + "ipub": '{"bibliography": "example.bib", "biboptions": ["super", "sort"], "bibstyle": "unsrtnat", "language": "portuges", "listcode": true, "listfigures": true, "listtables": true, "titlepage": {"author": "Authors Name", "email": "authors@email.com", "institution": ["Institution1", "Institution2"], "logo": "logo_example.png", "subtitle": "Sub-Title", "supervisors": ["First Supervisor", "Second Supervisor"], "tagline": "A tagline for the report.", "title": "Main-Title"}, "toc": {"depth": 2}, "pandoc": {"use_numref": true, "at_notation": true}, "sphinx": {"bib_title": "My Bibliography"}}', + "jupytext": '{"metadata_filter": {"notebook": "ipub"}}', + "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.6.2"}', + "latex_envs": '{"LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "example.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": {"equation": "Ctrl-E", "itemize": "Ctrl-I"}, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": true}', + "nav_menu": "{}", + "toc": '{"colors": {"hover_highlight": "#DAA520", "navigate_num": "#000000", "navigate_text": "#333333", "running_highlight": "#FF0000", "selected_highlight": "#FFD700", "sidebar_border": "#EEEEEE", "wrapper_background": "#FFFFFF"}, "moveMenuLeft": true, "nav_menu": {"height": "161px", "width": "252px"}, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": false, "toc_section_display": "block", "toc_window_display": true, "widenNotebook": false}', + "varInspector": '{"cols": {"lenName": 16, "lenType": 16, "lenVar": 40}, "kernels_config": {"python": {"delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())"}, "r": {"delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) "}}, "types_to_exclude": ["module", "function", "builtin_function_or_method", "instance", "_Feature"], "window_display": false}', + } } file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml") diff --git a/tests/test_text_based.py b/tests/test_text_based.py index ceb059be..348eac68 100644 --- a/tests/test_text_based.py +++ b/tests/test_text_based.py @@ -9,6 +9,14 @@ def test_basic_run(sphinx_run, file_regression, check_nbs): sphinx_run.build() # print(sphinx_run.status()) assert sphinx_run.warnings() == "" - assert sphinx_run.app.env.metadata == {"basic_unrun": {"author": "Chris"}} + assert sphinx_run.app.env.metadata == { + "basic_unrun": { + "jupytext": '{"text_representation": {"extension": ".md", "format_name": "myst", "format_version": "0.8", "jupytext_version": "1.4.1+dev"}}', + "kernelspec": '{"display_name": "Python 3", "language": "python", "name": "python3"}', + "author": "Chris", + "source_map": "[13, 19]", + "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.7.3"}', + } + } file_regression.check(sphinx_run.get_nb(), check_fn=check_nbs, extension=".ipynb") file_regression.check(sphinx_run.get_doctree().pformat(), extension=".xml")