Exemplo n.º 1
0
def test_only_outputs(db, reset_diff_targets):
    base = db["mixed-conflicts--1"]
    local = db["mixed-conflicts--2"]
    remote = db["mixed-conflicts--3"]
    set_notebook_diff_targets(False, True, False, False)

    merge_args = copy.deepcopy(args)
    merge_args.merge_strategy = "mergetool"

    partial, decisions = merge_notebooks(base, local, remote, merge_args)

    assert len(decisions) > 0
    for d in decisions:
        path = d['common_path']
        # Still have some decisions on cell root, so avoid with len == 2 check
        assert len(path) == 2 or path[2] == 'outputs'
Exemplo n.º 2
0
def test_only_outputs(db, reset_diff_targets):
    base = db["mixed-conflicts--1"]
    local = db["mixed-conflicts--2"]
    remote = db["mixed-conflicts--3"]
    set_notebook_diff_targets(False, True, False, False)

    merge_args = copy.deepcopy(args)
    merge_args.merge_strategy = "mergetool"

    partial, decisions = merge_notebooks(base, local, remote, merge_args)

    assert len(decisions) > 0
    for d in decisions:
        path = d['common_path']
        # Still have some decisions on cell root, so avoid with len == 2 check
        assert len(path) == 2 or path[2] == 'outputs'
from docutils.nodes import image as image_node
from nbconvert.filters import strip_ansi
from nbdime.diffing.notebooks import (
    diff_notebooks,
    set_notebook_diff_ignores,
    set_notebook_diff_targets,
)
from nbdime.prettyprint import pretty_print_diff
from sphinx.util.console import nocolor

pytest_plugins = "sphinx.testing.fixtures"

# -Diff Configuration-#
NB_VERSION = 4
set_notebook_diff_ignores({"/nbformat_minor": True})
set_notebook_diff_targets(metadata=False)

TEST_FILE_DIR = Path(__file__).parent.joinpath("notebooks")


@pytest.fixture(autouse=True, scope="session")
def build_matplotlib_font_cache():
    """This is to mitigate errors on CI VMs, where you can get the message:
    "Matplotlib is building the font cache" in output notebooks
    """
    from matplotlib.font_manager import FontManager

    FontManager()


@pytest.fixture()
Exemplo n.º 4
0
def reset_diff_targets():
    try:
        yield
    finally:
        # Reset diff targets (global variable)
        set_notebook_diff_targets()
Exemplo n.º 5
0
import sphinx
import re
import sys
if sys.version_info.major == 2:
    import fnmatch

SPHINX_VERSION = sphinx.version_info
CONFIGSETS = {
    'base': "jupyter",
    'project': "jupyter",
}

#-Diff Configuration-#
NB_VERSION = 4
set_notebook_diff_ignores({"/nbformat_minor": True})
set_notebook_diff_targets(metadata=False, identifier=False)

# Specify which version of sphinx that should exclude comparison files
SPHINX_VERSION_EXCLUDE = {1: ['index*']}


def python27_glob(path, pattern):
    matches = []
    for root, dirnames, filenames in os.walk(path):
        for filename in fnmatch.filter(filenames, pattern):
            matches.append(os.path.join(root, filename))
    return matches


def check_set(PATH, BUILDER):
    if sys.version_info.major == 2:
Exemplo n.º 6
0
 def teardown(self):
     set_notebook_diff_targets(True, True, True, True)
Exemplo n.º 7
0
def reset_diff_targets():
    try:
        yield
    finally:
        # Reset diff targets (global variable)
        set_notebook_diff_targets()