Run tests under setup.py

pull/21458/head
Richard Belleville 5 years ago
parent 6055bc564d
commit d4e8d9956c
  1. 1
      src/python/grpcio_tests/tests/tests.json
  2. 1
      src/python/grpcio_tests/tests/unit/BUILD.bazel
  3. 8
      src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py
  4. 7
      tools/distrib/python/grpcio_tools/_parallel_compile_patch.py
  5. 5
      tools/distrib/python/grpcio_tools/grpc_tools/test/protoc_test.py

@ -49,6 +49,7 @@
"unit._cython.cygrpc_test.SecureServerSecureClient", "unit._cython.cygrpc_test.SecureServerSecureClient",
"unit._cython.cygrpc_test.TypeSmokeTest", "unit._cython.cygrpc_test.TypeSmokeTest",
"unit._dns_resolver_test.DNSResolverTest", "unit._dns_resolver_test.DNSResolverTest",
"unit._dynamic_stubs_test.DynamicStubTest",
"unit._empty_message_test.EmptyMessageTest", "unit._empty_message_test.EmptyMessageTest",
"unit._error_message_encoding_test.ErrorMessageEncodingTest", "unit._error_message_encoding_test.ErrorMessageEncodingTest",
"unit._exit_test.ExitTest", "unit._exit_test.ExitTest",

@ -112,7 +112,6 @@ py_library(
for test_file_name in GRPCIO_TESTS_UNIT for test_file_name in GRPCIO_TESTS_UNIT
] ]
# TODO: Somehow incorporate into setup.py workflow.
py2and3_test( py2and3_test(
name = "_dynamic_stubs_test", name = "_dynamic_stubs_test",
size = "small", size = "small",

@ -27,6 +27,14 @@ import functools
def _grpc_tools_unimportable(): def _grpc_tools_unimportable():
original_sys_path = sys.path original_sys_path = sys.path
sys.path = [path for path in sys.path if "grpcio_tools" not in path] sys.path = [path for path in sys.path if "grpcio_tools" not in path]
try:
import grpc_tools
except ImportError:
pass
else:
del grpc_tools
sys.path = original_sys_path
raise unittest.SkipTest("Failed to make grpc_tools unimportable.")
try: try:
yield yield
finally: finally:

@ -22,9 +22,10 @@ import os
try: try:
BUILD_EXT_COMPILER_JOBS = int( BUILD_EXT_COMPILER_JOBS = int(
os.environ.get('GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS', '1')) os.environ.get('GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS'))
except ValueError: except KeyError:
BUILD_EXT_COMPILER_JOBS = 1 import multiprocessing
BUILD_EXT_COMPILER_JOBS = multiprocessing.cpu_count()
# monkey-patch for parallel compilation # monkey-patch for parallel compilation

@ -109,9 +109,6 @@ def _test_syntax_errors():
assert False, "Compile error expected. None occurred." assert False, "Compile error expected. None occurred."
# TODO: Test warnings.
class ProtocTest(unittest.TestCase): class ProtocTest(unittest.TestCase):
def test_import_protos(self): def test_import_protos(self):
@ -138,8 +135,6 @@ class ProtocTest(unittest.TestCase):
def test_syntax_errors(self): def test_syntax_errors(self):
_run_in_subprocess(_test_syntax_errors) _run_in_subprocess(_test_syntax_errors)
# TODO: Write test to ensure the right module loader is used.
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save