File: test_saving.py

package info (click to toggle)
python-graphviz 0.20.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,188 kB
  • sloc: python: 4,098; makefile: 13
file content (14 lines) | stat: -rw-r--r-- 463 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import graphviz


def test_saves_source_from_file(tmp_path, src='graph spam { spam }'):
    path = tmp_path / 'spam.gv'
    path.write_text(src)
    stat_before = path.stat()

    source = graphviz.Source.from_file(path)
    source.save()

    assert path.stat().st_mtime == stat_before.st_mtime, 'file not overwritten'
    assert path.read_text() == src, 'file contents unchanged'
    assert ''.join(source) == f'{src}\n', 'src with final newline'