Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_render_svg(capsys):
output = dump_graphviz(tree, output_format='svg')
print_graphviz(output)
out, _ = capsys.readouterr()
assert out.startswith('')
def test_render_pdf():
output = dump_graphviz(tree, output_format='pdf')
@contextmanager
def redirect_stdout(new_target):
old_target, sys.stdout = sys.stdout, new_target
try:
yield new_target
finally:
sys.stdout = old_target
f = NamedTemporaryFile(delete=False)
with redirect_stdout(f):
print_graphviz(output)
with open(f.name, 'rb') as rf:
out = rf.read()
os.remove(f.name)
assert out[:4] == b'%PDF'