示例#1
0
    def test(self, tmpdir):
        text = 'Hello, World!'
        dirpath = tmpdir.dirname
        deploy(dirpath, text)

        filepath = os.path.join(dirpath, 'index.html')
        with open(filepath, mode='r') as f:
            result = f.read()

        assert text == result
def cmd(tool_opts, open_browser, tool, source):
    with tempdir() as dirpath:
        server = Server()
        source_abspath = os.path.abspath(source)
        command_instance = get_command(tool, source_abspath, dirpath,
                                       tool_opts)
        command_str = str(command_instance)
        sh = shell(command_str, cwd=dirpath)
        sh()
        server.watch(source, sh)

        image_filepath = command_instance.destination
        image_filename = os.path.basename(image_filepath)

        page = render(image_filename)
        deploy(dirpath, page)

        server.serve(root=dirpath, open_url_delay=open_browser)