tests.test_compatibility_impl   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A TestCompatibilityImpl.test_get_args_and_return_type() 0 6 1
A TestCompatibilityImpl.test_get_args_and_return_type_no_return_type() 0 6 1
A TestCompatibilityImpl.test_get_args_and_return_type_no_args() 0 6 1
A TestCompatibilityImpl.test_get_args_and_return_type_no_hints() 0 8 1
1
from typing import Callable
2
from unittest import TestCase
3
from jacked._compatibility_impl import get_args_and_return_type
4
from jacked._typing import NoneType
5
6
7
class TestCompatibilityImpl(TestCase):
8
9
    def test_get_args_and_return_type(self):
10
        arg_types, return_type = get_args_and_return_type(
11
            Callable[[int, str], float])
12
13
        self.assertEqual((int, str), arg_types)
14
        self.assertEqual(float, return_type)
15
16
    def test_get_args_and_return_type_no_args(self):
17
        arg_types, return_type = get_args_and_return_type(
18
            Callable[[], float])
19
20
        self.assertEqual(tuple(), arg_types)
21
        self.assertEqual(float, return_type)
22
23
    def test_get_args_and_return_type_no_return_type(self):
24
        arg_types, return_type = get_args_and_return_type(
25
            Callable[[int, str], None])
26
27
        self.assertEqual((int, str), arg_types)
28
        self.assertEqual(NoneType, return_type)
29
30
    def test_get_args_and_return_type_no_hints(self):
31
        arg_types1, return_type1 = get_args_and_return_type(Callable)
32
        arg_types2, return_type2 = get_args_and_return_type(callable)
33
34
        self.assertEqual(None, arg_types1)
35
        self.assertEqual(None, return_type1)
36
        self.assertEqual(None, arg_types2)
37
        self.assertEqual(None, return_type2)
38