Merge pull request #15113 from mehrdada/pylint-tests-1

Eliminate some of the more esoteric pylint suppressions for tests
pull/15085/merge
Mehrdad Afshari 7 years ago committed by GitHub
commit b3069b095d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      .pylintrc-tests
  2. 2
      src/python/grpcio_tests/tests/_loader.py
  3. 4
      src/python/grpcio_tests/tests/_result.py
  4. 4
      src/python/grpcio_tests/tests/interop/client.py
  5. 4
      src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py
  6. 2
      src/python/grpcio_tests/tests/stress/test_runner.py
  7. 24
      src/python/grpcio_tests/tests/testing/_client_application.py
  8. 2
      src/python/grpcio_tests/tests/testing/_server_application.py
  9. 4
      src/python/grpcio_tests/tests/unit/_compression_test.py
  10. 2
      src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
  11. 4
      src/python/grpcio_tests/tests/unit/_cython/test_utilities.py
  12. 2
      src/python/grpcio_tests/tests/unit/_exit_test.py
  13. 2
      src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py
  14. 4
      src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
  15. 2
      src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py

@ -39,28 +39,16 @@ disable=
too-many-public-methods,
too-many-locals,
redefined-variable-type,
old-style-class,
redefined-outer-name,
bare-except,
broad-except,
ungrouped-imports,
too-many-branches,
too-many-arguments,
too-many-format-args,
too-many-return-statements,
too-many-statements,
undefined-variable,
function-redefined,
unnecessary-lambda,
wildcard-import,
line-too-long,
unreachable,
wrong-import-position,
wrong-import-order,
non-iterator-returned,
undefined-loop-variable,
raising-bad-type,
bad-continuation,
# -- END OF TEST-SPECIFIC SUPPRESSIONS --

@ -54,7 +54,7 @@ class Loader(object):
for module in modules:
try:
package_paths = module.__path__
except:
except AttributeError:
continue
self.walk_packages(package_paths)
coverage_context.stop()

@ -46,7 +46,7 @@ class CaseResult(
None.
"""
class Kind:
class Kind(object):
UNTESTED = 'untested'
RUNNING = 'running'
ERROR = 'error'
@ -257,7 +257,7 @@ class CoverageResult(AugmentedResult):
#coverage.Coverage().combine()
class _Colors:
class _Colors(object):
"""Namespaced constants for terminal color magic numbers."""
HEADER = '\033[95m'
INFO = '\033[94m'

@ -66,10 +66,6 @@ def _args():
return parser.parse_args()
def _application_default_credentials():
return oauth2client_client.GoogleCredentials.get_application_default()
def _stub(args):
target = '{}:{}'.format(args.server_host, args.server_port)
if args.test_case == 'oauth2_auth_token':

@ -329,9 +329,7 @@ class PythonPluginTest(unittest.TestCase):
_packagify(self._python_out)
with _system_path([
self._python_out,
]):
with _system_path([self._python_out]):
self._payload_pb2 = importlib.import_module(_PAYLOAD_PB2)
self._requests_pb2 = importlib.import_module(_REQUESTS_PB2)
self._responses_pb2 = importlib.import_module(_RESPONSES_PB2)

@ -50,7 +50,7 @@ class TestRunner(threading.Thread):
test_case.test_interoperability(self._stub, None)
end_time = time.time()
self._histogram.add((end_time - start_time) * 1e9)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
traceback.print_exc()
self._exception_queue.put(
Exception("An exception occured during test {}"

@ -215,30 +215,6 @@ def _run_infinite_request_stream(stub):
return _UNSATISFACTORY_OUTCOME
def run(scenario, channel):
stub = services_pb2_grpc.FirstServiceStub(channel)
try:
if scenario is Scenario.UNARY_UNARY:
return _run_unary_unary(stub)
elif scenario is Scenario.UNARY_STREAM:
return _run_unary_stream(stub)
elif scenario is Scenario.STREAM_UNARY:
return _run_stream_unary(stub)
elif scenario is Scenario.STREAM_STREAM:
return _run_stream_stream(stub)
elif scenario is Scenario.CONCURRENT_STREAM_UNARY:
return _run_concurrent_stream_unary(stub)
elif scenario is Scenario.CONCURRENT_STREAM_STREAM:
return _run_concurrent_stream_stream(stub)
elif scenario is Scenario.CANCEL_UNARY_UNARY:
return _run_cancel_unary_unary(stub)
elif scenario is Scenario.INFINITE_REQUEST_STREAM:
return _run_infinite_request_stream(stub)
except grpc.RpcError as rpc_error:
return Outcome(Outcome.Kind.RPC_ERROR, rpc_error.code(),
rpc_error.details())
_IMPLEMENTATIONS = {
Scenario.UNARY_UNARY: _run_unary_unary,
Scenario.UNARY_STREAM: _run_unary_stream,

@ -38,7 +38,7 @@ class FirstServiceServicer(services_pb2_grpc.FirstServiceServicer):
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details('Something is wrong with your request!')
return
yield services_pb2.Strange()
yield services_pb2.Strange() # pylint: disable=unreachable
def StreUn(self, request_iterator, context):
context.send_initial_metadata(((

@ -52,9 +52,9 @@ class _MethodHandler(grpc.RpcMethodHandler):
self.stream_unary = None
self.stream_stream = None
if self.request_streaming and self.response_streaming:
self.stream_stream = lambda x, y: handle_stream(x, y)
self.stream_stream = handle_stream
elif not self.request_streaming and not self.response_streaming:
self.unary_unary = lambda x, y: handle_unary(x, y)
self.unary_unary = handle_unary
class _GenericHandler(grpc.GenericRpcHandler):

@ -285,7 +285,7 @@ class ServerClientMixin(object):
self.assertEqual(5, len(server_event.batch_operations))
found_server_op_types = set()
for server_result in server_event.batch_operations:
self.assertNotIn(client_result.type(), found_server_op_types)
self.assertNotIn(server_result.type(), found_server_op_types)
found_server_op_types.add(server_result.type())
if server_result.type() == cygrpc.OperationType.receive_message:
self.assertEqual(REQUEST, server_result.message())

@ -25,7 +25,7 @@ class SimpleFuture(object):
def wrapped_function():
try:
self._result = function(*args, **kwargs)
except Exception as error:
except Exception as error: # pylint: disable=broad-except
self._error = error
self._result = None
@ -41,7 +41,7 @@ class SimpleFuture(object):
self._thread.join()
if self._error:
# TODO(atash): re-raise exceptions in a way that preserves tracebacks
raise self._error
raise self._error # pylint: disable=raising-bad-type
return self._result

@ -49,7 +49,7 @@ def cleanup_processes():
for process in processes:
try:
process.kill()
except Exception:
except Exception: # pylint: disable=broad-except
pass

@ -14,7 +14,7 @@
_BEFORE_IMPORT = tuple(globals())
from grpc import *
from grpc import * # pylint: disable=wildcard-import
_AFTER_IMPORT = tuple(globals())

@ -165,11 +165,13 @@ class FailAfterFewIterationsCounter(object):
def __next__(self):
if self._current >= self._high:
raise Exception("This is a deliberate failure in a unit test.")
raise test_control.Defect()
else:
self._current += 1
return self._bytestring
next = __next__
def _unary_unary_multi_callable(channel):
return channel.unary_unary(_UNARY_UNARY)

@ -65,7 +65,7 @@ class _Servicer(object):
self._serviced = True
self._condition.notify_all()
return
yield
yield # pylint: disable=unreachable
def stream_unary(self, request_iterator, context):
for request in request_iterator:

Loading…
Cancel
Save