1
- from inspect import signature
2
-
1
+ from ..compat import PY3 , signature
3
2
from ..typecheck import compatible
4
3
5
4
@@ -18,48 +17,6 @@ def bar(): # pragma: nocover
18
17
assert compatible (bar , bar )
19
18
20
19
21
- def test_allow_new_params_with_defaults ():
22
-
23
- @signature
24
- def iface (a , b , c ): # pragma: nocover
25
- pass
26
-
27
- @signature
28
- def impl (a , b , c , d = 3 , e = 5 , * , f = 5 ): # pragma: nocover
29
- pass
30
-
31
- assert compatible (impl , iface )
32
- assert not compatible (iface , impl )
33
-
34
-
35
- def test_allow_reorder_kwonlys ():
36
-
37
- @signature
38
- def foo (a , b , c , * , d , e , f ): # pragma: nocover
39
- pass
40
-
41
- @signature
42
- def bar (a , b , c , * , f , d , e ): # pragma: nocover
43
- pass
44
-
45
- assert compatible (foo , bar )
46
- assert compatible (bar , foo )
47
-
48
-
49
- def test_allow_default_changes ():
50
-
51
- @signature
52
- def foo (a , b , c = 3 , * , d = 1 , e , f ): # pragma: nocover
53
- pass
54
-
55
- @signature
56
- def bar (a , b , c = 5 , * , f , e , d = 12 ): # pragma: nocover
57
- pass
58
-
59
- assert compatible (foo , bar )
60
- assert compatible (bar , foo )
61
-
62
-
63
20
def test_disallow_new_or_missing_positionals ():
64
21
65
22
@signature
@@ -101,15 +58,19 @@ def bar(b, a): # pragma: nocover
101
58
assert not compatible (bar , foo )
102
59
103
60
104
- def test_disallow_kwonly_to_positional ():
61
+ def test_allow_new_params_with_defaults_no_kwonly ():
105
62
106
63
@signature
107
- def foo (a , * , b ): # pragma: nocover
64
+ def iface (a , b , c ): # pragma: nocover
108
65
pass
109
66
110
67
@signature
111
- def bar (a , b ): # pragma: nocover
68
+ def impl (a , b , c , d = 3 , e = 5 , f = 5 ): # pragma: nocover
112
69
pass
113
70
114
- assert not compatible (foo , bar )
115
- assert not compatible (bar , foo )
71
+ assert compatible (impl , iface )
72
+ assert not compatible (iface , impl )
73
+
74
+
75
+ if PY3 : # pragma: nocover
76
+ from ._py3_typecheck_tests import *
0 commit comments