File: test_lib.py

package info (click to toggle)
propka 3.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: python: 7,156; makefile: 39
file content (27 lines) | stat: -rw-r--r-- 791 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
import propka.lib as m

import argparse
import pytest


def test_parse_res_string():
    assert m.parse_res_string("C:123") == ("C", 123, " ")
    assert m.parse_res_string("C:123B") == ("C", 123, "B")
    assert m.parse_res_string("ABC:123x") == ("ABC", 123, "x")
    with pytest.raises(ValueError):
        m.parse_res_string("C:B123")
    with pytest.raises(ValueError):
        m.parse_res_string("123B")
    with pytest.raises(ValueError):
        m.parse_res_string("C:123:B")


def test_parse_res_list():
    assert m.parse_res_list("C:123") == [("C", 123, " ")]
    assert m.parse_res_list("ABC:123,D:4,F:56X") == [
        ("ABC", 123, " "),
        ("D", 4, " "),
        ("F", 56, "X"),
    ]
    with pytest.raises(argparse.ArgumentTypeError):
        m.parse_res_list("C:B123")