@@ -645,11 +645,11 @@ def test_bound_method_introspection(self):
645
645
646
646
def test_unbound_method_retrieval (self ):
647
647
obj = self .A
648
- self .assertFalse ( hasattr ( obj .both , "__self__" ) )
649
- self .assertFalse ( hasattr ( obj .nested , "__self__" ) )
650
- self .assertFalse ( hasattr ( obj .over_partial , "__self__" ) )
651
- self .assertFalse ( hasattr ( obj .static , "__self__" ) )
652
- self .assertFalse ( hasattr ( self .a .static , "__self__" ) )
648
+ self .assertNotHasAttr ( obj .both , "__self__" )
649
+ self .assertNotHasAttr ( obj .nested , "__self__" )
650
+ self .assertNotHasAttr ( obj .over_partial , "__self__" )
651
+ self .assertNotHasAttr ( obj .static , "__self__" )
652
+ self .assertNotHasAttr ( self .a .static , "__self__" )
653
653
654
654
def test_descriptors (self ):
655
655
for obj in [self .A , self .a ]:
@@ -791,7 +791,7 @@ def wrapper():
791
791
self .assertNotEqual (wrapper .__qualname__ , f .__qualname__ )
792
792
self .assertEqual (wrapper .__doc__ , None )
793
793
self .assertEqual (wrapper .__annotations__ , {})
794
- self .assertFalse ( hasattr ( wrapper , 'attr' ) )
794
+ self .assertNotHasAttr ( wrapper , 'attr' )
795
795
796
796
def test_selective_update (self ):
797
797
def f ():
@@ -840,7 +840,7 @@ def wrapper():
840
840
pass
841
841
functools .update_wrapper (wrapper , max )
842
842
self .assertEqual (wrapper .__name__ , 'max' )
843
- self .assertTrue (wrapper .__doc__ . startswith ( 'max(' ) )
843
+ self .assertStartsWith (wrapper .__doc__ , 'max(' )
844
844
self .assertEqual (wrapper .__annotations__ , {})
845
845
846
846
def test_update_type_wrapper (self ):
@@ -910,7 +910,7 @@ def wrapper():
910
910
self .assertEqual (wrapper .__name__ , 'wrapper' )
911
911
self .assertNotEqual (wrapper .__qualname__ , f .__qualname__ )
912
912
self .assertEqual (wrapper .__doc__ , None )
913
- self .assertFalse ( hasattr ( wrapper , 'attr' ) )
913
+ self .assertNotHasAttr ( wrapper , 'attr' )
914
914
915
915
def test_selective_update (self ):
916
916
def f ():
@@ -2666,15 +2666,15 @@ def _(self, arg):
2666
2666
a .t (0 )
2667
2667
self .assertEqual (a .arg , "int" )
2668
2668
aa = A ()
2669
- self .assertFalse ( hasattr ( aa , 'arg' ) )
2669
+ self .assertNotHasAttr ( aa , 'arg' )
2670
2670
a .t ('' )
2671
2671
self .assertEqual (a .arg , "str" )
2672
2672
aa = A ()
2673
- self .assertFalse ( hasattr ( aa , 'arg' ) )
2673
+ self .assertNotHasAttr ( aa , 'arg' )
2674
2674
a .t (0.0 )
2675
2675
self .assertEqual (a .arg , "base" )
2676
2676
aa = A ()
2677
- self .assertFalse ( hasattr ( aa , 'arg' ) )
2677
+ self .assertNotHasAttr ( aa , 'arg' )
2678
2678
2679
2679
def test_staticmethod_register (self ):
2680
2680
class A :
@@ -3036,16 +3036,16 @@ def i(arg):
3036
3036
@i .register (42 )
3037
3037
def _ (arg ):
3038
3038
return "I annotated with a non-type"
3039
- self .assertTrue (str (exc .exception ). startswith ( msg_prefix + "42" ) )
3040
- self .assertTrue (str (exc .exception ). endswith ( msg_suffix ) )
3039
+ self .assertStartsWith (str (exc .exception ), msg_prefix + "42" )
3040
+ self .assertEndsWith (str (exc .exception ), msg_suffix )
3041
3041
with self .assertRaises (TypeError ) as exc :
3042
3042
@i .register
3043
3043
def _ (arg ):
3044
3044
return "I forgot to annotate"
3045
- self .assertTrue (str (exc .exception ). startswith ( msg_prefix +
3045
+ self .assertStartsWith (str (exc .exception ), msg_prefix +
3046
3046
"<function TestSingleDispatch.test_invalid_registrations.<locals>._"
3047
- ))
3048
- self .assertTrue (str (exc .exception ). endswith ( msg_suffix ) )
3047
+ )
3048
+ self .assertEndsWith (str (exc .exception ), msg_suffix )
3049
3049
3050
3050
with self .assertRaises (TypeError ) as exc :
3051
3051
@i .register
@@ -3055,23 +3055,23 @@ def _(arg: typing.Iterable[str]):
3055
3055
# types from `typing`. Instead, annotate with regular types
3056
3056
# or ABCs.
3057
3057
return "I annotated with a generic collection"
3058
- self .assertTrue (str (exc .exception ). startswith (
3058
+ self .assertStartsWith (str (exc .exception ),
3059
3059
"Invalid annotation for 'arg'."
3060
- ))
3061
- self .assertTrue (str (exc .exception ). endswith (
3060
+ )
3061
+ self .assertEndsWith (str (exc .exception ),
3062
3062
'typing.Iterable[str] is not a class.'
3063
- ))
3063
+ )
3064
3064
3065
3065
with self .assertRaises (TypeError ) as exc :
3066
3066
@i .register
3067
3067
def _ (arg : typing .Union [int , typing .Iterable [str ]]):
3068
3068
return "Invalid Union"
3069
- self .assertTrue (str (exc .exception ). startswith (
3069
+ self .assertStartsWith (str (exc .exception ),
3070
3070
"Invalid annotation for 'arg'."
3071
- ))
3072
- self .assertTrue (str (exc .exception ). endswith (
3071
+ )
3072
+ self .assertEndsWith (str (exc .exception ),
3073
3073
'typing.Union[int, typing.Iterable[str]] not all arguments are classes.'
3074
- ))
3074
+ )
3075
3075
3076
3076
def test_invalid_positional_argument (self ):
3077
3077
@functools .singledispatch
0 commit comments