File: test_errors.py

package info (click to toggle)
vulture 2.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: python: 3,254; makefile: 12
file content (35 lines) | stat: -rw-r--r-- 634 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest

from vulture.utils import ExitCode

from . import call_vulture, v

assert v  # Silence pyflakes.


def test_syntax_error(v):
    v.scan("foo bar")
    assert int(v.report()) == ExitCode.InvalidInput


def test_null_byte(v):
    v.scan("\x00")
    assert int(v.report()) == ExitCode.InvalidInput


def test_confidence_range(v):
    v.scan(
        """\
def foo():
    pass
"""
    )
    with pytest.raises(ValueError):
        v.get_unused_code(min_confidence=150)


def test_invalid_cmdline_args():
    assert (
        call_vulture(["vulture/", "--invalid-argument"])
        == ExitCode.InvalidCmdlineArguments
    )