How to use the pipdeptree.print_graphviz function in pipdeptree

To help you get started, we’ve selected a few pipdeptree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naiquevin / pipdeptree / tests / test_pipdeptree.py View on Github external
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'
github naiquevin / pipdeptree / tests / test_pipdeptree.py View on Github external
def test_render_svg(capsys):
    output = dump_graphviz(tree, output_format='svg')
    print_graphviz(output)
    out, _ = capsys.readouterr()
    assert out.startswith('')
github naiquevin / pipdeptree / tests / test_pipdeptree.py View on Github external
def test_render_json(capsys):
    output = render_json(tree, indent=4)
    print_graphviz(output)
    out, _ = capsys.readouterr()
    assert out.startswith('[\n    {\n        "')
    assert out.strip().endswith('}\n]')
    data = json.loads(out)
    assert 'package' in data[0]
    assert 'dependencies' in data[0]