_sanity/_sanity_test.py
Go to the documentation of this file.
1 # Copyright 2016 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import json
16 import pkgutil
17 import unittest
18 
19 import six
20 
21 import tests
22 
23 
24 class SanityTest(unittest.TestCase):
25 
26  maxDiff = 32768
27 
28  TEST_PKG_MODULE_NAME = 'tests'
29  TEST_PKG_PATH = 'tests'
30 
32  """Autodiscovers all test suites and checks that tests.json is up to date"""
33  loader = tests.Loader()
34  loader.loadTestsFromNames([self.TEST_PKG_MODULE_NAME])
35  test_suite_names = sorted({
36  test_case_class.id().rsplit('.', 1)[0] for test_case_class in
38  })
39 
40  tests_json_string = pkgutil.get_data(self.TEST_PKG_PATH, 'tests.json')
41  tests_json = json.loads(
42  tests_json_string.decode() if six.PY3 else tests_json_string)
43 
44  self.assertSequenceEqual(tests_json, test_suite_names)
45 
46 
47 if __name__ == '__main__':
48  unittest.main(verbosity=2)
tests._sanity._sanity_test.SanityTest.TEST_PKG_MODULE_NAME
string TEST_PKG_MODULE_NAME
Definition: _sanity/_sanity_test.py:28
tests.Loader
Loader
Definition: src/python/grpcio_tests/tests/__init__.py:20
tests._sanity._sanity_test.SanityTest.testTestsJsonUpToDate
def testTestsJsonUpToDate(self)
Definition: _sanity/_sanity_test.py:31
tests._loader.iterate_suite_cases
def iterate_suite_cases(suite)
Definition: _loader.py:89
tests._sanity._sanity_test.SanityTest
Definition: _sanity/_sanity_test.py:24
tests._sanity._sanity_test.SanityTest.TEST_PKG_PATH
string TEST_PKG_PATH
Definition: _sanity/_sanity_test.py:29


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:38