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_main_show_only_and_exclude_fails(monkeypatch):
parser = get_parser()
args = parser.parse_args('--packages Flask --exclude Jinja2,Flask'.split())
def _get_args():
return args
monkeypatch.setattr('pipdeptree._get_args', _get_args)
with pytest.raises(SystemExit):
main()
def test_main_show_only_and_exclude_ok(monkeypatch):
parser = get_parser()
args = parser.parse_args('--packages Flask --exclude Jinja2'.split())
def _get_args():
return args
monkeypatch.setattr('pipdeptree._get_args', _get_args)
assert main() == 0
def test_parser_json_tree():
parser = get_parser()
args = parser.parse_args(['--json-tree'])
assert args.json_tree
assert not args.json
assert args.output_format is None
def test_parser_svg():
parser = get_parser()
args = parser.parse_args(['--graph-output', 'svg'])
assert args.output_format == 'svg'
assert not args.json
def test_parser_json():
parser = get_parser()
args = parser.parse_args(['--json'])
assert args.json
assert args.output_format is None
def test_parser_j():
parser = get_parser()
args = parser.parse_args(['-j'])
assert args.json
assert args.output_format is None
def test_main_basic(monkeypatch):
parser = get_parser()
args = parser.parse_args('')
def _get_args():
return args
monkeypatch.setattr('pipdeptree._get_args', _get_args)
assert main() == 0
def test_parser_pdf():
parser = get_parser()
args = parser.parse_args(['--graph-output', 'pdf'])
assert args.output_format == 'pdf'
assert not args.json
def test_parser_default():
parser = get_parser()
args = parser.parse_args([])
assert not args.json
assert args.output_format is None