Exemplo n.º 1
0
def test_from_file(tmpdir, filename='hello.gv', directory='source_hello',
                   data=u'digraph { hello -> world }', encoding='utf-8'):
    lpath = tmpdir.mkdir(directory)
    lpath.join(filename).write_text(data, encoding=encoding)

    source = Source.from_file(filename, str(lpath))

    assert source.encoding == 'utf-8'

    source = Source.from_file(filename, str(lpath), encoding=encoding)

    assert source.source == data
    assert source.filename == filename
    assert source.directory == str(lpath)
    assert source.encoding == encoding
Exemplo n.º 2
0
def test_from_file(tmpdir, filename='hello.gv', directory='source_hello',
                   data=u'digraph { hello -> world }', encoding='utf-8'):
    lpath = tmpdir.mkdir(directory)
    (lpath / filename).write_text(data, encoding=encoding)

    source = Source.from_file(filename, str(lpath))
    assert source.encoding == 'utf-8'

    source = Source.from_file(filename, str(lpath), encoding=None)
    assert source.encoding == locale.getpreferredencoding()

    source = Source.from_file(filename, str(lpath), encoding=encoding)
    assert source.source == data
    assert source.filename == filename
    assert source.directory == str(lpath)
    assert source.encoding == encoding
Exemplo n.º 3
0
def test_from_file(tmp_path, filename='hello.gv', directory='source_hello',
                   data='digraph { hello -> world }', encoding='utf-8'):
    lpath = tmp_path / directory
    lpath.mkdir()
    (lpath / filename).write_text(data, encoding=encoding)

    source = Source.from_file(filename, str(lpath))
    assert source.encoding == 'utf-8'

    source = Source.from_file(filename, str(lpath), encoding=None)
    assert source.encoding == locale.getpreferredencoding()

    source = Source.from_file(filename, str(lpath), encoding=encoding)
    assert source.source == data
    assert source.filename == filename
    assert source.directory == str(lpath)
    assert source.encoding == encoding
Exemplo n.º 4
0
def get_graphviz_source(filename, directory=None, format='dot', engine='dot'):
    from graphviz.files import Source

    src = Source.from_file(filename,
                           directory=directory,
                           format=format,
                           engine=engine)
    src.filename = filename[:-4]
    return src