Ejemplo n.º 1
0
def test_load_jupytext_configuration_file(tmpdir, config_file):
    full_config_path = tmpdir.join(config_file)

    if config_file.endswith(("jupytext", ".toml")):
        full_config_path.write("""default_jupytext_formats = "ipynb,py:percent"
default_notebook_metadata_filter = "all"
default_cell_metadata_filter = "all"
""")
    elif config_file.endswith(".yml"):
        full_config_path.write("""default_jupytext_formats: ipynb,py:percent
default_notebook_metadata_filter: all
default_cell_metadata_filter: all
""")
    elif config_file.endswith(".json"):
        full_config_path.write(
            """{"default_jupytext_formats": "ipynb,py:percent",
"default_notebook_metadata_filter": "all",
"default_cell_metadata_filter": "all"
}
""")
    elif config_file.endswith(".py"):
        full_config_path.write(
            """c.default_jupytext_formats = "ipynb,py:percent"
c.default_notebook_metadata_filter = "all"
c.default_cell_metadata_filter = "all"
""")

    config = load_jupytext_configuration_file(str(full_config_path))
    assert config.default_jupytext_formats == "ipynb,py:percent"
    assert config.default_notebook_metadata_filter == "all"
    assert config.default_cell_metadata_filter == "all"
Ejemplo n.º 2
0
def test_deprecated_options_cause_warning(tmpdir, option_name):
    jupytext_toml = tmpdir.join("jupytext.toml")
    jupytext_toml.write(f"default_{option_name} = 'value'")
    config = load_jupytext_configuration_file(str(jupytext_toml))
    fmt = {}
    with pytest.warns(FutureWarning, match=f"use '{option_name}'"):
        config.set_default_format_options(fmt)
        assert fmt[option_name] == "value"
Ejemplo n.º 3
0
def test_deprecated_formats_cause_warning(
        tmpdir, content_toml="default_jupytext_formats = 'ipynb,md'"):
    jupytext_toml = tmpdir.join("jupytext.toml")
    jupytext_toml.write(content_toml)

    config = load_jupytext_configuration_file(str(jupytext_toml))
    with pytest.warns(FutureWarning, match="use 'formats'"):
        assert config.default_formats(str(
            tmpdir.join("test.md"))) == "ipynb,md"
Ejemplo n.º 4
0
def test_jupytext_formats(tmpdir, content_toml, formats_short_form):
    jupytext_toml = tmpdir.join("jupytext.toml")
    jupytext_toml.write(content_toml)

    config = load_jupytext_configuration_file(str(jupytext_toml))
    assert config.formats == formats_short_form