def test_export():
    tmpdir = tempfile.mkdtemp()
    env = dict(os.environ)
    env.update(NBPRESENT_TEST_HTTP_PORT=str(unused_port()),
               PATH=os.pathsep.join([env["PATH"], node_bin()]))

    httpd = subprocess.Popen([
        sys.executable, "-m", http_module, env["NBPRESENT_TEST_HTTP_PORT"],
        "--bind=127.0.0.1"
    ],
                             cwd=tmpdir)

    try:
        export(join(here, "notebooks", "Basics.ipynb"),
               join(tmpdir, "Basics.html"), "html")
        args = [
            "casperjs{}".format(".cmd" if IS_WIN else ""),
            "test",
            "--fail-fast",
            "--includes={}".format(",".join(glob(join(here, 'js', '_*.js')))),
        ] + glob(join(here, 'js', 'test_export_*.js'))

        proc = subprocess.Popen(args, stderr=subprocess.PIPE, env=env)
        proc.communicate()

        assert proc.returncode == 0
    finally:
        httpd.kill()
Esempio n. 2
0
def test_export():
    tmpdir = tempfile.mkdtemp()
    env = dict(os.environ)
    env.update(
        NBPRESENT_TEST_HTTP_PORT=str(unused_port()),
        PATH=os.pathsep.join([env["PATH"], node_bin()])
    )

    httpd = subprocess.Popen([
            sys.executable, "-m", http_module,
            env["NBPRESENT_TEST_HTTP_PORT"],
            "--bind=127.0.0.1"
        ],
        cwd=tmpdir)

    try:
        export(
            join(here, "notebooks", "Basics.ipynb"),
            join(tmpdir, "Basics.html"),
            "html")
        args = [
            "casperjs{}".format(".cmd" if IS_WIN else ""),
            "test",
            "--fail-fast",
            "--includes={}".format(
                ",".join(glob(join(here, 'js', '_*.js')))),
        ] + glob(join(here, 'js', 'test_export_*.js'))

        proc = subprocess.Popen(
            args,
            stderr=subprocess.PIPE,
            env=env
        )
        proc.communicate()

        assert proc.returncode == 0
    finally:
        httpd.kill()
Esempio n. 3
0
def test_export():
    tmpdir = tempfile.mkdtemp()
    env = dict(os.environ)
    env.update(NBPRESENT_TEST_HTTP_PORT=str(unused_port()))

    httpd = subprocess.Popen(
        [sys.executable, "-m", http_module, env["NBPRESENT_TEST_HTTP_PORT"], "--bind=127.0.0.1"], cwd=tmpdir
    )

    try:
        export(join(here, "notebooks", "Basics.ipynb"), join(tmpdir, "Basics.html"), "html")

        assert (
            0
            == subprocess.Popen(
                ["casperjs", "test", "--includes={}".format(",".join(glob(join(here, "js", "_*.js"))))]
                + glob(join(here, "js", "test_export_*.js")),
                env=env,
            ).wait()
        )
    finally:
        httpd.kill()
        shutil.rmtree(tmpdir)