diff options
author | Mehrdad Afshari <mehrdada@users.noreply.github.com> | 2018-04-19 11:23:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-19 11:23:49 -0700 |
commit | b3069b095d797496e068f622257498e8158557c7 (patch) | |
tree | 40609fb66f74751ffd2ebdae0809971d6fb929a4 /src | |
parent | 1d74fa67480550b0476b45c9fc5030e5478efc5a (diff) | |
parent | dd9697fef8103b93cc9ecfbc71fa83cd838f1398 (diff) |
Merge pull request #15113 from mehrdada/pylint-tests-1
Eliminate some of the more esoteric pylint suppressions for tests
Diffstat (limited to 'src')
14 files changed, 17 insertions, 45 deletions
diff --git a/src/python/grpcio_tests/tests/_loader.py b/src/python/grpcio_tests/tests/_loader.py index 31680916b4..be0af64646 100644 --- a/src/python/grpcio_tests/tests/_loader.py +++ b/src/python/grpcio_tests/tests/_loader.py @@ -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() diff --git a/src/python/grpcio_tests/tests/_result.py b/src/python/grpcio_tests/tests/_result.py index 9907c4e1f9..b105f18e78 100644 --- a/src/python/grpcio_tests/tests/_result.py +++ b/src/python/grpcio_tests/tests/_result.py @@ -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' diff --git a/src/python/grpcio_tests/tests/interop/client.py b/src/python/grpcio_tests/tests/interop/client.py index 3780ed9020..698c37017f 100644 --- a/src/python/grpcio_tests/tests/interop/client.py +++ b/src/python/grpcio_tests/tests/interop/client.py @@ -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': diff --git a/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py b/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py index ad0ecf0079..b46e53315e 100644 --- a/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py +++ b/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py @@ -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) diff --git a/src/python/grpcio_tests/tests/stress/test_runner.py b/src/python/grpcio_tests/tests/stress/test_runner.py index d5038e3ba2..764cda17fb 100644 --- a/src/python/grpcio_tests/tests/stress/test_runner.py +++ b/src/python/grpcio_tests/tests/stress/test_runner.py @@ -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 {}" diff --git a/src/python/grpcio_tests/tests/testing/_client_application.py b/src/python/grpcio_tests/tests/testing/_client_application.py index 7d0d74c8c4..3ddeba2373 100644 --- a/src/python/grpcio_tests/tests/testing/_client_application.py +++ b/src/python/grpcio_tests/tests/testing/_client_application.py @@ -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, diff --git a/src/python/grpcio_tests/tests/testing/_server_application.py b/src/python/grpcio_tests/tests/testing/_server_application.py index 02769ca68d..243c385daf 100644 --- a/src/python/grpcio_tests/tests/testing/_server_application.py +++ b/src/python/grpcio_tests/tests/testing/_server_application.py @@ -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((( diff --git a/src/python/grpcio_tests/tests/unit/_compression_test.py b/src/python/grpcio_tests/tests/unit/_compression_test.py index 7550cd39ba..0b11f03adf 100644 --- a/src/python/grpcio_tests/tests/unit/_compression_test.py +++ b/src/python/grpcio_tests/tests/unit/_compression_test.py @@ -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): diff --git a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py index 9045ff58a0..23f5ef605d 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py +++ b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py @@ -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()) diff --git a/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py b/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py index 4a00b9ef2f..7d5eaaaa84 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py +++ b/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py @@ -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 diff --git a/src/python/grpcio_tests/tests/unit/_exit_test.py b/src/python/grpcio_tests/tests/unit/_exit_test.py index 6e6d9de0fb..f40f3ae07c 100644 --- a/src/python/grpcio_tests/tests/unit/_exit_test.py +++ b/src/python/grpcio_tests/tests/unit/_exit_test.py @@ -49,7 +49,7 @@ def cleanup_processes(): for process in processes: try: process.kill() - except Exception: + except Exception: # pylint: disable=broad-except pass diff --git a/src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py b/src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py index e683131722..ad847ae03e 100644 --- a/src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py +++ b/src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py @@ -14,7 +14,7 @@ _BEFORE_IMPORT = tuple(globals()) -from grpc import * +from grpc import * # pylint: disable=wildcard-import _AFTER_IMPORT = tuple(globals()) diff --git a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py index e40cca8b24..93a5fdf9ff 100644 --- a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py +++ b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py @@ -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) diff --git a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py index 61c03f64ba..b43c647fc9 100644 --- a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py +++ b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py @@ -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: |