File: test_utils.py

package info (click to toggle)
python-typeguard 4.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 544 kB
  • sloc: python: 6,271; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

from typeguard._utils import function_name, qualified_name

from . import Child


@pytest.mark.parametrize(
    "inputval, add_class_prefix, expected",
    [
        pytest.param(qualified_name, False, "function", id="func"),
        pytest.param(Child(), False, "tests.Child", id="instance"),
        pytest.param(int, False, "int", id="builtintype"),
        pytest.param(int, True, "class int", id="builtintype_classprefix"),
    ],
)
def test_qualified_name(inputval, add_class_prefix, expected):
    assert qualified_name(inputval, add_class_prefix=add_class_prefix) == expected


def test_function_name():
    assert function_name(function_name) == "typeguard._utils.function_name"