Debian Codegraph @

src/python/grpcio_tests/tests/_sanity/_sanity_test.py

raw
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 tests
20
21
22 class SanityTest(unittest.TestCase):
23
24 maxDiff = 32768
25
26 TEST_PKG_MODULE_NAME = 'tests'
27 TEST_PKG_PATH = 'tests'
28
29 def testTestsJsonUpToDate(self):
30 """Autodiscovers all test suites and checks that tests.json is up to date"""
31 loader = tests.Loader()
32 loader.loadTestsFromNames([self.TEST_PKG_MODULE_NAME])
33 test_suite_names = sorted({
34 test_case_class.id().rsplit('.', 1)[0] for test_case_class in
35 tests._loader.iterate_suite_cases(loader.suite)
36 })
37
38 tests_json_string = pkgutil.get_data(self.TEST_PKG_PATH, 'tests.json')
39 tests_json = tests_json_string.decode()
40
41 self.assertSequenceEqual(tests_json, test_suite_names)
42
43
44 if __name__ == '__main__':
45 unittest.main(verbosity=2)