repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
jupytext
tests/integration/cli/test_cli_pipe.py
.py
import pytest from jupytext.cli import jupytext @pytest.mark.requires_myst @pytest.mark.requires_black def test_cli_black_myst( tmp_path, no_jupytext_version_number, text="""--- jupytext: formats: md:myst text_representation: extension: .md format_name: myst format_version: 0.13 kernelspe...
38
655
jupytext
tests/integration/cli/test_execute.py
.py
import shutil from io import StringIO from unittest import mock import pytest from jupytext import read, reads from jupytext.cli import jupytext from jupytext.version import __version__ @pytest.mark.requires_user_kernel_python3 @pytest.mark.requires_nbconvert @pytest.mark.skip_on_windows def test_pipe_nbconvert_exe...
301
7,746
jupytext
tests/functional/metadata/test_metadata_filters_from_config.py
.py
import nbformat import pytest import yaml from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_notebooks from jupytext.header import _JUPYTER_METADATA_NAMESPACE def test_metadata_filters_from_conf...
81
2,458
jupytext
tests/functional/metadata/test_metadata_filter.py
.py
from copy import deepcopy import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import reads, writes from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_notebooks from jupytext.metadata_filter import filter_metadata, metadata_filter_as_dict ...
206
6,372
jupytext
tests/functional/config/test_config.py
.py
import os from pathlib import Path from contextlib import contextmanager import pytest from jupytext.config import ( find_jupytext_configuration_file, load_jupytext_configuration_file, notebook_formats, ) from jupytext.jupytext import load_jupytext_config, read @contextmanager def change_dir(path): ...
419
13,546
jupytext
tests/functional/docs/test_doc_files_are_notebooks.py
.py
from pathlib import Path import pytest from jupytext import read def documentation_files(): for path in (Path(__file__).parent / "../../../docs").iterdir(): if path.suffix == ".md": yield path @pytest.mark.parametrize( "doc_file", documentation_files(), ids=[doc_file.stem for d...
28
601
jupytext
tests/functional/docs/test_changelog.py
.py
import re import sys from pathlib import Path import pytest from jupytext.version import __version__ def replace_issue_number_with_links(text): return re.sub( r"([^\[-])#([0-9]+)", r"\1[#\2](https://github.com/mwouts/jupytext/issues/\2)", text, ) @pytest.mark.parametrize( "input...
75
2,371
jupytext
tests/functional/contents_manager/test_async_and_sync_contents_manager_are_in_sync.py
.py
from pathlib import Path import pytest from black import FileMode, format_str from jupytext.async_contentsmanager import __file__ as async_contentsmanager_file from jupytext.async_pairs import __file__ as async_pairs_file from jupytext.sync_contentsmanager import __file__ as sync_contentsmanager_file from jupytext.sy...
56
1,846
jupytext
tests/functional/cli/test_source_is_newer.py
.py
""" Here we test the --check-source-is-newer option of the jupytext CLI """ import os from jupytext import cli from jupytext import write import pytest def test_check_source_is_newer_when_using_jupytext_to(tmp_path, python_notebook): tmp_ipynb = tmp_path / "notebook.ipynb" tmp_py = tmp_path / "notebook.py" ...
71
3,127
jupytext
tests/functional/cli/test_synchronous_changes.py
.py
""" These tests ensure that Jupytext raises an error when a file loaded by Jupytext changes while Jupytext is running. To make the simultaneous change occur in the tests, we monkey-patch the function `create_prefix_dir` which is called just before writing the file back to disk. """ from jupytext import cli from jupyt...
112
4,449
jupytext
tests/functional/cli/test_cli.py
.py
import os import sys import time import unittest.mock as mock import warnings from argparse import ArgumentTypeError from io import StringIO from shutil import copyfile from subprocess import check_call import nbformat import pytest from jupyter_client.kernelspec import find_kernel_specs, get_kernel_spec from jupyter_...
1,538
48,329
jupytext
tests/functional/cli/test_cli_config.py
.py
import nbformat import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext.cli import jupytext from jupytext.compare import compare from jupytext.header import header_to_metadata_and_cell from jupytext.jupytext import read, write def test_pairing_through_config_leaves_ipynb_unmodified(tmp...
192
5,299
jupytext
tests/functional/round_trip/test_rmd_to_ipynb.py
.py
import jupytext from jupytext.compare import compare def test_identity_write_read(rmd_file, no_jupytext_version_number): """Test that writing the notebook with ipynb, and read again, yields identity""" with open(rmd_file) as fp: rmd = fp.read() nb = jupytext.reads(rmd, "Rmd") rmd2 = jupytext...
31
730
jupytext
tests/functional/round_trip/test_myst_header.py
.py
import pytest from nbformat.v4.nbbase import new_notebook, new_raw_cell from jupytext import reads, writes from jupytext.compare import compare, compare_notebooks from jupytext.config import load_jupytext_configuration_file from jupytext.header import _JUPYTER_METADATA_NAMESPACE from jupytext.myst import dump_yaml_blo...
139
3,572
jupytext
tests/functional/round_trip/test_read_all_py.py
.py
import jupytext from jupytext.compare import compare def test_identity_source_write_read(py_file): with open(py_file) as fp: py = fp.read() nb = jupytext.reads(py, "py") py2 = jupytext.writes(nb, "py") compare(py2, py)
13
247
jupytext
tests/functional/round_trip/test_mirror.py
.py
"""Here we generate mirror representation of py, Rmd and ipynb files as py or ipynb, and make sure that these representations minimally change on new releases. """ import os import re import pytest from nbformat.v4.nbbase import new_notebook import jupytext from jupytext.compare import ( assert_conversion_same_a...
181
6,146
jupytext
tests/functional/round_trip/test_jupytext_nbconvert_round_trip.py
.py
import pytest import jupytext from jupytext.header import header_to_metadata_and_cell @pytest.mark.requires_nbconvert def test_markdown_jupytext_nbconvert_is_identity(md_file): """Test that a Markdown file, converted to a notebook, then exported back to Markdown with nbconvert, yields the original file""" ...
84
2,991
jupytext
tests/functional/others/test_preserve_empty_cells.py
.py
import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks @pytest.mark.parametrize("blank_lines", range(1, 6)) def test_file_with_blank_lines(blank_lines): py_script = """# Markdown cell{0} # Another one{0} ...
33
1,051
jupytext
tests/functional/others/test_custom_cell_magics.py
.py
import nbformat from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare_notebooks from jupytext.languages import _JUPYTER_LANGUAGES_LOWER_AND_UPPER def test_custom_cell_magics( tmpdir, nb=new_notebook( cells=[ ...
43
1,253
jupytext
tests/functional/others/test_jupytext_read.py
.py
import pytest import jupytext from jupytext.compare import compare_notebooks def test_as_version_has_appropriate_type(): with pytest.raises(TypeError): jupytext.read("script.py", "py:percent") def test_read_file_with_explicit_fmt(tmpdir): tmp_py = str(tmpdir.join("notebook.py")) with open(tmp_...
26
510
jupytext
tests/functional/others/test_cell_tags_are_preserved.py
.py
import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell from jupytext import reads, writes from jupytext.formats import formats_with_support_for_cell_metadata, is_myst_available @pytest.fixture() def notebook_with_tags(python_notebook): nb = python_notebook nb.cells = [ new_code...
30
1,063
jupytext
tests/functional/others/test_combine.py
.py
from copy import deepcopy import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.combine import combine_inputs_with_outputs from jupytext.compare import compare, compare_notebooks def test_combine(): ...
225
5,481
jupytext
tests/functional/others/test_doxygen.py
.py
import nbformat import pytest import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_notebooks from jupytext.doxygen import doxygen_to_markdown, markdown_to_doxygen SAMPLE_MARKDOWN = """A latex formula $$1+1$$, another one $$2+2 $$ An inline formula $3+3$ """ ...
74
1,954
jupytext
tests/functional/others/test_sample_notebooks_are_normalized.py
.py
import nbformat import pytest from packaging import version import jupytext @pytest.mark.skipif( version.parse(nbformat.__version__) <= version.parse("5.7"), reason="normalize is not available", ) def test_sample_notebooks_are_normalized(any_nb_file): if "myst/" in any_nb_file and not jupytext.myst.is_my...
29
817
jupytext
tests/functional/others/test_raw_strings.py
.py
import pytest from nbformat.v4.nbbase import new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare def test_markdown_cell_with_backslash_is_encoded_with_raw_string( nb=new_notebook(cells=[new_markdown_cell(r"A $\LaTeX$ expression")]), py=r'''# %% [markdown] r""" A $\LaTeX$ expr...
43
1,118
jupytext
tests/functional/others/test_unicode.py
.py
from nbformat.v4.nbbase import new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare def test_notebook_contents_is_unicode(ipynb_file): nb = jupytext.read(ipynb_file) for cell in nb.cells: assert isinstance(cell.source, str) def test_rmd_notebook_contents_is_unicode(...
140
2,877
jupytext
tests/functional/others/test_cells.py
.py
import pytest from nbformat.v4.nbbase import new_markdown_cell from jupytext.cell_reader import ( LightScriptCellReader, RMarkdownCellReader, paragraph_is_fully_commented, uncomment, ) from jupytext.cell_to_text import RMarkdownCellExporter @pytest.mark.parametrize( "lines", [ "# text...
190
4,383
jupytext
tests/functional/others/test_invalid_file.py
.py
"""Jupytext should refuse to open a file with invalid content""" from pathlib import Path import pytest from jupyter_server.utils import ensure_async from tornado.web import HTTPError from jupytext import read from jupytext.cli import jupytext as jupytext_cli @pytest.fixture def invalid_md_file(): return Path(...
36
1,004
jupytext
tests/functional/others/test_custom_language_magics.py
.py
import nbformat from nbformat.v4.nbbase import new_code_cell, new_notebook import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare_notebooks def test_custom_language_magics_md_to_ipynb(): """Code blocks in custom language magics should be converted to code cells""" ...
108
2,880
jupytext
tests/functional/others/test_hide_remove_input_outputs_rmarkdown.py
.py
import pytest import jupytext from jupytext.compare import compare, compare_notebooks @pytest.mark.parametrize( "md,rmd", [ ('tags=["remove_cell"]', "include=FALSE"), ('tags=["remove_output"]', "results='hide'"), ('tags=["remove_output"]', 'results="hide"'), ('tags=["remove_in...
89
1,947
jupytext
tests/functional/others/test_cell_markers.py
.py
from nbformat.v4.nbbase import new_raw_cell from jupytext import reads, writes from jupytext.cli import jupytext def test_set_cell_markers_cli(tmpdir, cwd_tmpdir): tmpdir.join("test.py").write("# %% [markdown]\n# A Markdown cell\n") jupytext(["--format-options", 'cell_markers="""', "test.py"]) py = tmpdi...
34
800
jupytext
tests/functional/others/test_read_write_functions.py
.py
from io import StringIO from pathlib import Path import nbformat from nbformat.v4.nbbase import new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks def test_simple_hook(tmpdir): nb_file = str(tmpdir.join("notebook.ipynb")) md_file = str(tmpdir.join("notebo...
87
1,993
jupytext
tests/functional/others/test_write_does_not_modify_notebook.py
.py
from copy import deepcopy import pytest from jupytext import read, write, writes from jupytext.compare import compare from jupytext.formats import long_form_one_format @pytest.mark.parametrize( "fmt", ["auto:light", "auto:percent", "md", ".Rmd", ".ipynb"], ) def test_write_notebook_does_not_change_it(ipynb_...
25
672
jupytext
tests/functional/others/test_remove_encoding.py
.py
import pytest from jupyter_server.utils import ensure_async @pytest.mark.asyncio async def test_remove_encoding_907(tmp_path, python_notebook, cm): # Pair all notebooks to py:percent files (tmp_path / "jupytext.toml").write_text('formats="ipynb,py:percent"') # Create a contents manager cm.root_dir = ...
46
1,522
jupytext
tests/functional/others/test_active_cells.py
.py
import pytest from nbformat import NotebookNode import jupytext from jupytext.compare import compare, compare_cells HEADER = { ".py": """# --- # jupyter: # jupytext: # main_language: python # --- """, ".R": """# --- # jupyter: # jupytext: # main_language: python # --- """, ".md": """--- jupy...
368
9,335
jupytext
tests/functional/others/test_nbformat_version.py
.py
import pytest from nbformat import writes as nbformat_writes from nbformat.v3.nbbase import new_code_cell, new_notebook, new_text_cell, new_worksheet from nbformat.v4.nbbase import new_markdown_cell from nbformat.v4.nbbase import new_notebook as new_notebook_v4 from jupytext import reads, writes from jupytext.jupytext...
57
1,873
jupytext
tests/functional/others/test_jupytext_errors.py
.py
import pytest from nbformat.v4.nbbase import new_notebook import jupytext from jupytext.formats import JupytextFormatError def test_read_wrong_ext(tmpdir, nb_file="notebook.ext"): nb_file = tmpdir.join(nb_file) nb_file.write("{}") with pytest.raises(JupytextFormatError): jupytext.read(str(nb_file...
19
516
jupytext
tests/functional/others/test_auto_ext.py
.py
import pytest from jupytext import read, reads, writes from jupytext.formats import JupytextFormatError, auto_ext_from_metadata def test_auto_in_fmt(ipynb_py_R_file): nb = read(ipynb_py_R_file) auto_ext = auto_ext_from_metadata(nb.metadata) fmt = auto_ext[1:] + ":percent" text = writes(nb, "auto:perc...
68
2,340
jupytext
tests/functional/others/test_trust_notebook.py
.py
""" A notebook is trusted when all its outputs are trusted. Hence, a trusted notebook that is updated using Jupytext should remain trusted, as no new outputs are added. """ import os import shutil import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_code_cell, new_notebook, n...
321
10,954
jupytext
tests/functional/others/test_save_multiple.py
.py
import os import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_notebook from nbformat.validator import NotebookValidationError from tornado.web import HTTPError import jupytext from jupytext.compare import compare_notebooks, notebook_model pytestmark = pytest.mark.asyncio ...
122
3,310
jupytext
tests/functional/others/test_cell_metadata.py
.py
import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell import jupytext from jupytext.cell_metadata import ( _IGNORE_CELL_METADATA, RMarkdownOptionParsingError, is_valid_metadata_key, metadata_to_rmd_options, metadata_to_text, parse_key_equal_value, parse_rmd_options, ...
267
9,615
jupytext
tests/functional/others/test_pytest.py
.py
import pytest from jupytext.cli import jupytext def test_run_pytest_ok( tmpdir, text="""This is a notebook with a test that is supposed to pass ```python def test_ok(): assert True ``` """, ): tmp_md = str(tmpdir.join("notebook.md")) with open(tmp_md, "w") as fp: fp.write(text) jupyte...
36
712
jupytext
tests/functional/simple_notebooks/test_read_simple_sphinx.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script='''# -*- coding: utf-8 -*- """ This is a markdown cell """ 1 + 2 + 3 + 4 5 6 "" 7 ################################# # Another markdown cell def f(x): """Sample docstring""" return 4 ''', ): nb = jupytext.reads(scr...
141
2,895
jupytext
tests/functional/simple_notebooks/test_read_simple_R.py
.py
import pytest import jupytext from jupytext.compare import compare @pytest.mark.parametrize("ext", [".r", ".R"]) def test_read_simple_file( ext, rnb="""#' --- #' title: Simple file #' --- #' Here we have some text #' And below we have some R code f <- function(x) { x + 1 } h <- function(y) y ...
204
4,460
jupytext
tests/functional/simple_notebooks/test_read_incomplete_rmd.py
.py
import jupytext def test_incomplete_header( rmd="""--- title: Incomplete header ```{python} 1+1 ``` """, ): nb = jupytext.reads(rmd, "Rmd") assert len(nb.cells) == 2 assert nb.cells[0].cell_type == "markdown" assert nb.cells[0].source == "---\ntitle: Incomplete header" assert nb.cells[1].cell...
89
1,798
jupytext
tests/functional/simple_notebooks/test_read_simple_percent.py
.py
import os import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) import jupytext from jupytext.compare import compare, compare_notebooks, notebook_model def test_read_simple_file( script="""# --...
609
12,956
jupytext
tests/functional/simple_notebooks/test_knitr_spin.py
.py
import jupytext def test_jupytext_same_as_knitr_spin(r_spin_file, tmpdir): nb = jupytext.read(r_spin_file) rmd_jupytext = jupytext.writes(nb, "Rmd") # Rmd file generated with spin(hair='R/spin.R', knit=FALSE) rmd_file = r_spin_file.replace("R_spin", "Rmd").replace(".R", ".Rmd") with open(rmd_fil...
15
396
jupytext
tests/functional/simple_notebooks/test_read_simple_clojure.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script=""";; --- ;; title: Simple file ;; --- ;; Here we have some text ;; And below we have some code ((fn [] (println "Hello World"))) """, ): nb = jupytext.reads(script, "clj") assert len(nb.cells) == 3 assert nb....
34
760
jupytext
tests/functional/simple_notebooks/test_read_simple_markdown.py
.py
from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) import jupytext from jupytext.combine import combine_inputs_with_outputs from jupytext.compare import compare, compare_cells, compare_notebooks def test_read_mostly_py_markdown_file( markdown="""--- t...
937
19,110
jupytext
tests/functional/simple_notebooks/test_read_simple_rmd.py
.py
import re from time import sleep import nbformat import pytest from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_cells, compare_notebooks def...
306
7,005
jupytext
tests/functional/simple_notebooks/test_read_folding_markers.py
.py
import jupytext from jupytext.compare import compare # region Folding markers as cell boundaries # region Sub-region with metadata {"key": "value"} def test_mark_cell_with_vim_folding_markers( script="""# This is a markdown cell # {{{ And this is a foldable code region with metadata {"key": "value"} a = 1 b = 2...
147
3,482
jupytext
tests/functional/simple_notebooks/test_read_simple_hydrogen.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script="""# --- # title: Simple file # --- # %% [markdown] # This is a markdown cell # %% [raw] # This is a raw cell # %%% sub-cell title # This is a sub-cell # %%%% sub-sub-cell title # This is a sub-sub-cell # %% And now a code...
191
3,695
jupytext
tests/functional/simple_notebooks/test_read_simple_csharp.py
.py
import pytest import jupytext from jupytext.compare import compare @pytest.mark.parametrize("lang", ["cs", "c#", "csharp"]) def test_simple_cs(lang): source = """// A Hello World! program in C#. Console.WriteLine("Hello World!"); """ md = """```{lang} {source} ``` """.format(lang=lang, source=source) nb ...
80
1,821
jupytext
tests/functional/simple_notebooks/test_read_simple_ipynb.py
.py
import nbformat from nbformat.v4.nbbase import new_notebook import jupytext from jupytext.compare import compare def test_save_ipynb_with_jupytext_has_final_newline(tmpdir): nb = new_notebook() file_jupytext = str(tmpdir.join("jupytext.ipynb")) file_nbformat = str(tmpdir.join("nbformat.ipynb")) jupy...
24
607
jupytext
tests/functional/simple_notebooks/test_ipynb_to_rmd.py
.py
import nbformat import jupytext from jupytext.compare import compare_notebooks def test_identity_source_write_read(ipynb_py_R_jl_file): """Test that writing the notebook with rmd, and read again, is the same as removing outputs""" with open(ipynb_py_R_jl_file) as fp: nb1 = nbformat.read(fp, as_v...
18
446
jupytext
tests/functional/simple_notebooks/test_read_simple_matlab.py
.py
from nbformat.v4.nbbase import new_code_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks def test_hide_code_tag( no_jupytext_version_number, nb=new_notebook( metadata={"jupytext": {"main_language": "matlab"}}, cells=[new_code_cell("1 + 1", metadata={"...
37
961
jupytext
tests/functional/simple_notebooks/test_read_simple_rust.py
.py
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks def test_read_magics(text="// :vars\n"): nb = jupytext.reads(text, "rs") compare_notebooks(nb, new_notebook(cells=[new_code_cell(":vars")])) compare(jupyte...
88
2,011
jupytext
tests/functional/simple_notebooks/test_ipynb_to_myst.py
.py
import json import unittest.mock as mock from textwrap import dedent import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_notebook from tornado.web import HTTPError import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare from jup...
260
6,896
jupytext
tests/functional/simple_notebooks/test_read_dotnet_try_markdown.py
.py
import jupytext from jupytext.cell_metadata import parse_key_equal_value from jupytext.compare import compare def test_parse_metadata(): assert parse_key_equal_value("--key value --key-2 .\\a\\b.cs") == { "incorrectly_encoded_metadata": "--key value --key-2 .\\a\\b.cs" } def test_parse_double_hyphen...
50
1,571
jupytext
tests/functional/simple_notebooks/test_read_simple_ocaml.py
.py
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks def test_read_simple_code( no_jupytext_version_number, ml="""(* %% *) let sum x y = x + y """, nb=new_notebook( cells=[ new_code_cell("...
39
904
jupytext
tests/functional/simple_notebooks/test_read_empty_text_notebook.py
.py
import pytest from nbformat.notebooknode import NotebookNode import jupytext from jupytext.formats import NOTEBOOK_EXTENSIONS from jupytext.myst import is_myst_available, myst_extensions from jupytext.quarto import is_quarto_available @pytest.mark.parametrize("ext", sorted(set(NOTEBOOK_EXTENSIONS) - {".ipynb"})) def...
24
778
jupytext
tests/functional/simple_notebooks/test_read_simple_scheme.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script=""";; --- ;; title: Simple file ;; --- ;; Here we have some text ;; And below we have some code (define a 35) """, ): for file_extension in ("ss", "scm"): nb = jupytext.reads(script, file_extension) assert...
28
784
jupytext
tests/functional/simple_notebooks/test_read_simple_julia.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( julia='''""" cube(x) Compute the cube of `x`, ``x^3``. # Examples ```jldoctest julia> cube(2) 8 ``` """ function cube(x) x^3 end cube(x) # And a markdown comment ''', ): nb = jupytext.reads(julia, "jl") assert nb.met...
54
888
jupytext
tests/functional/simple_notebooks/test_read_simple_nomarker.py
.py
import os import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from jupytext import reads, write, writes from jupytext.cli import jupytext as jupytext_cli from jupytext.combine import combine_inputs_with_outputs from jupytext.compare import compare def test_write_reload_simple...
65
1,944
jupytext
tests/functional/simple_notebooks/test_read_simple_java.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script="""// --- // title: Simple file // --- // Here we have some text // And below we have some code System.out.println("Hello World"); """, ): nb = jupytext.reads(script, "java") assert len(nb.cells) == 3 assert nb.ce...
27
733
jupytext
tests/functional/simple_notebooks/test_read_simple_go.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( go="""// -*- coding: utf-8 -*- // --- // jupyter: // kernelspec: // display_name: Go (gonb) // language: go // name: gonb // --- // A notebook that use [GoNB](https://github.com/janpfeifer/gonb) // the code below comes...
157
3,169
jupytext
tests/functional/simple_notebooks/test_read_simple_python.py
.py
import pytest from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) import jupytext from jupytext.compare import compare, compare_notebooks def test_read_simple_file( pynb="""# --- # title: Simple file # --- # Here we have some text # And below we have ...
1,188
25,334
jupytext
tests/functional/simple_notebooks/test_ipynb_to_py.py
.py
import nbformat import jupytext from jupytext.compare import compare_notebooks def test_identity_source_write_read(ipynb_py_file): """Test that writing the notebook with jupytext, and read again, is the same as removing outputs""" with open(ipynb_py_file) as fp: nb1 = nbformat.read(fp, as_versio...
18
430
jupytext
tests/functional/simple_notebooks/test_ipynb_to_R.py
.py
import nbformat import pytest import jupytext from jupytext.compare import compare_notebooks @pytest.mark.parametrize("ext", [".r", ".R"]) def test_identity_source_write_read(ipynb_R_file, ext): """ Test that writing the notebook with R, and read again, is the same as removing outputs """ with o...
22
492
jupytext
tests/functional/simple_notebooks/test_read_simple_groovy.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( script="""// --- // title: Simple file // --- // Here we have some text // And below we have some code println("Hello World") """, ): nb = jupytext.reads(script, "groovy") assert len(nb.cells) == 3 assert nb.cells[0].cel...
27
713
jupytext
tests/unit/test_paired_paths.py
.py
import os import unittest.mock as mock import pytest import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare from jupytext.formats import ( long_form_multiple_formats, long_form_one_format, short_form_multiple_formats, ) from jupytext.paired_paths import ( ...
351
12,734
jupytext
tests/unit/test_escape_magics.py
.py
import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_code_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks, notebook_model from jupytext.magics import ( _PYTHON_MAGIC_ASSIGN, comment_magic, is_magic, uncomment_magic, ...
301
8,501
jupytext
tests/unit/test_formats.py
.py
import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_notebook import jupytext from jupytext.compare import compare from jupytext.formats import ( JupytextFormatError, divine_format, get_format_implementation, guess_format, long_form_multiple_formats, re...
422
10,853
jupytext
tests/unit/test_header.py
.py
from nbformat.v4.nbbase import new_markdown_cell, new_notebook, new_raw_cell import jupytext from jupytext.compare import compare from jupytext.formats import get_format_implementation from jupytext.header import ( header_to_metadata_and_cell, metadata_and_cell_to_header, recursive_update, uncomment_li...
206
5,200
jupytext
tests/unit/test_landing_page_notebook.py
.py
""" Tests for the landing page "Quarterly Sales" example notebook. Verifies that: 1. The notebook executes without errors. 2. Conversion to each text format matches the snapshot files in data/landing_page/. To update snapshots after a format change, run: UPDATE_SNAPSHOTS=1 pytest tests/unit/test_landing_page_not...
118
4,028
jupytext
tests/unit/test_stringparser.py
.py
from jupytext.stringparser import StringParser def test_long_string( text="""'''This is a multiline comment with "quotes", 'single quotes' # and comments and line breaks and it ends here''' 1 + 1 """, ): quoted = [] sp = StringParser("python") for i, line in enumerate(text.splitlines()): i...
80
1,412
jupytext
tests/unit/test_cell_id.py
.py
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_raw_cell def test_cell_id_is_not_random(): assert new_code_cell().id == "cell-1" assert new_code_cell().id == "cell-2" assert new_markdown_cell().id == "cell-3" assert new_raw_cell().id == "cell-4"
9
285
jupytext
tests/unit/test_pep8.py
.py
from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import read, reads, writes from jupytext.compare import compare from jupytext.pep8 import ( cell_ends_with_code, cell_ends_with_function_or_class, cell_has_code, next_instruction_is_function_or_class, pep8_lines_between_cells,...
210
5,189
jupytext
tests/unit/test_labconfig.py
.py
import json import pytest from jupytext_config.labconfig import LabConfig @pytest.fixture() def sample_viewer_config(): return { "@jupyterlab/docmanager-extension:plugin": { "defaultViewers": { "markdown": "Jupytext Notebook", "myst": "Jupytext Notebook", ...
54
1,646
jupytext
tests/unit/test_markdown_in_code_cells.py
.py
"""Issue #712""" import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import reads, writes from jupytext.cell_to_text import three_backticks_or_more from jupytext.compare import compare, compare_notebooks def test_three_backticks_or_more(): assert three_backticks_or_more([""]) ...
125
2,305
jupytext
tests/unit/test_compare.py
.py
import pytest from nbformat.v4.nbbase import ( new_code_cell, new_markdown_cell, new_notebook, new_raw_cell, ) from jupytext.compare import ( NotebookDifference, compare, compare_cells, compare_notebooks, ) from jupytext.compare import test_round_trip_conversion as round_trip_conversion...
301
9,750
jupytext
tests/unit/data/landing_page/notebook_light.py
.py
# # Quarterly Sales # A look at Q4 revenue by region. import pandas as pd df = pd.read_csv("sales.csv") df.groupby("region")["revenue"].sum().plot.bar()
8
155
jupytext
tests/unit/data/landing_page/notebook_marimo.py
.py
import marimo __generated_with = "0.19.4" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" # Quarterly Sales A look at Q4 revenue by region. """) return @app.cell def _(): import pandas as pd df = pd.read_csv("sales.csv") return (df,) @app.cell def _(df): df....
36
481
jupytext
tests/external/test_marimo.py
.py
from jupytext.marimo import marimo_py_to_notebook, notebook_to_marimo_py, marimo_version import pytest from nbformat.v4.nbbase import new_notebook, new_code_cell from jupytext.compare import compare, compare_notebooks from jupytext.formats import guess_format @pytest.fixture def py_marimo() -> str: return f"""imp...
45
995
jupytext
tests/external/conftest.py
.py
import pytest from git import Repo @pytest.fixture def tmp_repo(tmpdir): repo = Repo.init(str(tmpdir)) return repo
9
125
jupytext
tests/external/simple_external_notebooks/test_read_simple_quarto.py
.py
import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare, compare_notebooks @pytest.mark.requires_quarto def test_qmd_to_ipynb( qmd="""Some text ```{python} 1 + 1 ``` """, nb=new_notebook( cells=[ new...
38
914
jupytext
tests/external/simple_external_notebooks/test_read_simple_pandoc.py
.py
import pytest from nbformat.v4.nbbase import new_markdown_cell, new_notebook import jupytext from jupytext.cli import jupytext as jupytext_cli from jupytext.compare import compare, compare_notebooks from jupytext.pandoc import PandocError @pytest.mark.requires_pandoc def test_pandoc_implicit( cell_id, markdo...
87
2,163
jupytext
tests/external/jupyter_fs/test_jupyter_fs.py
.py
import logging import sys import pytest from jupyter_server.utils import ensure_async from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook import jupytext from jupytext.compare import compare_cells, notebook_model pytestmark = pytest.mark.skipif(sys.version_info >= (3, 12), reason="https://g...
111
4,119
jupytext
tests/external/pre_commit/test_pre_commit_4_sync_execute.py
.py
import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_code_cell from pre_commit.main import main as pre_commit from jupytext import read, write @pytest.mark.requires_user_kernel_python3 def test_pre_commit_hook_sync_execute( tmpdir, cwd_tmpdir, tmp_repo, jupytext_rep...
65
1,862
jupytext
tests/external/pre_commit/test_pre_commit_0_ipynb_to_py.py
.py
import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_markdown_cell, new_notebook from pre_commit.main import main as pre_commit from jupytext import read, write from jupytext.cli import jupytext from jupytext.compare import compare_cells def test_pre_commit_hook_ipynb_to_py(tmpdir,...
66
2,428
jupytext
tests/external/pre_commit/test_pre_commit_mode.py
.py
import os import time import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from jupytext import read, write from jupytext.cli import get_timestamp, git_timestamp, is_untracked, jupytext def test_is_untracked(tmpdir, cwd_tmpdir, tmp_repo): # make a test file file = "tes...
265
8,166
jupytext
tests/external/pre_commit/test_pre_commit_2_sync_nbstripout.py
.py
import pytest from git.exc import HookExecutionError from pre_commit.main import main as pre_commit from jupytext import read, write from jupytext.cli import jupytext def test_pre_commit_hook_sync_nbstripout( tmpdir, cwd_tmpdir, tmp_repo, jupytext_repo_root, jupytext_repo_rev, notebook_with_o...
65
1,665
jupytext
tests/external/pre_commit/test_pre_commit_1_sync_with_config.py
.py
import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_markdown_cell from pre_commit.main import main as pre_commit from jupytext import TextFileContentsManager, read def test_pre_commit_hook_sync_with_config( tmpdir, cwd_tmpdir, tmp_repo, jupytext_repo_root, jupy...
82
2,678
jupytext
tests/external/pre_commit/test_pre_commit_5_reformat_markdown.py
.py
import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from pre_commit.main import main as pre_commit from jupytext import read, write @pytest.mark.requires_pandoc def test_pre_commit_hook_sync_reformat_code_and_markdown( tmpdir, cwd...
118
3,342
jupytext
tests/external/pre_commit/test_pre_commit_3_sync_black_nbstripout.py
.py
import pytest from git.exc import HookExecutionError from pre_commit.main import main as pre_commit from jupytext import read, write import sys @pytest.mark.skipif(sys.version_info >= (3, 14), reason="this test fails on Python 3.14") def test_pre_commit_hook_sync_black_nbstripout( tmpdir, cwd_tmpdir, tmp...
77
2,092
jupytext
tests/external/pre_commit/test_pre_commit_1_sync.py
.py
import shutil import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_markdown_cell from pre_commit.main import main as pre_commit from jupytext import read, write from jupytext.cli import jupytext def test_pre_commit_hook_sync( tmpdir, cwd_tmpdir, tmp_repo, jupytext_...
109
3,161
jupytext
tests/external/pre_commit/test_pre_commit_1_sync_with_no_config.py
.py
from copy import deepcopy import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_markdown_cell from pre_commit.main import main as pre_commit import jupytext from jupytext import TextFileContentsManager from jupytext.compare import compare_notebooks def test_pre_commit_hook_sync_wit...
88
2,564
jupytext
tests/external/pre_commit/test_pre_commit_scripts.py
.py
import os import stat import unittest.mock as mock import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from jupytext import read, write from jupytext.cli import jupytext, system from jupytext.compare import compare_cells, compare_notebooks def git_in_tmpdir(tmpdir): """Re...
390
12,544
jupytext
tests/external/rst2md/test_rst2md.py
.py
import os import pytest from nbformat.v4.nbbase import new_markdown_cell, new_notebook from jupytext import TextFileContentsManager, read, write from jupytext.cli import jupytext @pytest.mark.requires_sphinx_gallery def test_rst2md(tmpdir, cwd_tmpdir): tmp_py = "notebook.py" tmp_ipynb = "notebook.ipynb" ...
70
1,723
jupytext
tests/external/docs/test_using_cli.py
.py
import os import shlex import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook import jupytext from jupytext.cli import jupytext as jupytext_cli doc_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "website", "src", "content", "docs") @pytest.mark.requires_user_kernel_python3 @pyte...
57
1,866