提交 23f98edd 编写于 作者: HansBug's avatar HansBug 😆

fix(hansbug): try simplify the saving of the images

上级 835d2268
......@@ -7,7 +7,7 @@ import zlib
import pytest
from click.testing import CliRunner
from hbutils.testing import cmdv
from hbutils.testing import cmdv, OS
from treevalue import FastTreeValue, dump, graphics
from treevalue.entry.cli import treevalue_cli
......@@ -244,4 +244,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 1000
if OS.windows:
assert os.path.getsize('test_graph.svg') <= 2000
else:
assert os.path.getsize('test_graph.svg') <= 1000
import codecs
import os
import shutil
import tempfile
import warnings
from collections import OrderedDict
from functools import partial
......@@ -61,10 +59,7 @@ def _save_source_code(g: Digraph, path: str):
def _save_image(g: Digraph, path: str, fmt: str):
with tempfile.TemporaryDirectory() as tmpdir:
with tempfile.NamedTemporaryFile(dir=tmpdir) as tmpfile:
svg_file = g.render(tmpfile.name, format=fmt)
shutil.copy(svg_file, path)
g.render(path, format=fmt)
_IMAGE_FMTS = {'svg', 'png'}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册