Example #1
0
def test_extra_config_have_precedenced(c):
    host = "leon"
    with tempdir() as tmpdir:
        with open("{}/config.conf".format(tmpdir), "w") as fh:
            fh.write(c.conf)
        cmd = '{} -C="{}" -E="system_path: /tmp/systest" {}'.format(c.loadconfig_cmd, tmpdir, host)
        ret = run(cmd)
    assert 'export SYSTEM_PATH="/tmp/systest"' in ret.stdout
Example #2
0
def test_convenient_config_file_from_directory(f):
    conf = "{color: [red, green, blue]}"
    with tempdir() as tmpdir:
        conf_file = "{}/config.conf".format(tmpdir)
        with open(conf_file, "w") as fh:
            fh.write(conf)
        c = Config(args=["-C={}".format(tmpdir)])
    assert conf == repr(c)
def test_fs_event_ctx():
    with tempdir() as tmpdir, fs_event_ctx(tmpdir, ["rst"]) as fs_event:
        filename = tmpdir + "/test.rst"
        open(filename, "w")
        assert filename == next(fs_event)

        filename = tmpdir + "/test2.rst"
        open(filename, "w")
        assert filename == next(fs_event)
def serve_ctx():
    """Functional serve context for testing core sphinxserve functionality"""

    c = Config(
        """\
        app: sphinxserve
        host: localhost
        port: 8888
        socket: $host:$port
        index_rst: |
            ================
            Test sphinxserve
            ================

            Simple sphinxserve test
        conf_py: |
            source_suffix = '.rst'
            master_doc = 'index'
        """
    )
    with tempdir() as tmpdir:
        c.tmpdir = tmpdir
        with open(tmpdir + "/conf.py", "w") as fh:
            fh.write(c.conf_py)
        with open(tmpdir + "/index.rst", "w") as fh:
            fh.write(c.index_rst)

        proc = Process(target=main, args=(["sphinxserve", tmpdir],))
        proc.start()
        try:
            check_host(c.host, c.port, timeout=5)
            yield c
        finally:
            proc.terminate()
            while proc.is_alive():
                sleep(0.1)
            proc.join()
Example #5
0
def test_Run_context():
    with tempdir() as tmp, Run("echo hi > " + tmp + "/test.txt"):
        with open(tmp + "/test.txt") as fh:
            assert "hi\n" == fh.read()
    assert not isfile(tmp + "/test.txt")