1414
1515"""Shared testing utilities."""
1616
17-
18- # Avoid the grpc and google.cloud.grpc collision.
1917from __future__ import absolute_import
2018
2119
2220class _Monkey (object ):
23- # context -manager for replacing module names in the scope of a test.
21+ """Context -manager for replacing module names in the scope of a test."""
2422
2523 def __init__ (self , module , ** kw ):
2624 self .module = module
27- if len ( kw ) == 0 : # pragma: NO COVER
25+ if not kw : # pragma: NO COVER
2826 raise ValueError ('_Monkey was used with nothing to monkey-patch' )
2927 self .to_restore = {key : getattr (module , key ) for key in kw }
3028 for key , value in kw .items ():
@@ -68,8 +66,12 @@ def _tempdir_mgr():
6866 return _tempdir_mgr
6967
7068
69+ # pylint: disable=invalid-name
70+ # Retain _tempdir as a constant for backwards compatibility despite
71+ # being an invalid name.
7172_tempdir = _tempdir_maker ()
7273del _tempdir_maker
74+ # pylint: enable=invalid-name
7375
7476
7577class _GAXBaseAPI (object ):
@@ -79,7 +81,8 @@ class _GAXBaseAPI(object):
7981 def __init__ (self , ** kw ):
8082 self .__dict__ .update (kw )
8183
82- def _make_grpc_error (self , status_code , trailing = None ):
84+ @staticmethod
85+ def _make_grpc_error (status_code , trailing = None ):
8386 from grpc ._channel import _RPCState
8487 from google .cloud .exceptions import GrpcRendezvous
8588
@@ -111,6 +114,7 @@ def __init__(self, *pages, **kwargs):
111114 self .page_token = kwargs .get ('page_token' )
112115
113116 def next (self ):
117+ """Iterate to the next page."""
114118 import six
115119 return six .next (self ._pages )
116120
0 commit comments