Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 1 | # Protocol Buffers - Google's data interchange format |
| 2 | # Copyright 2008 Google Inc. All rights reserved. |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 3 | # |
Joshua Haberman | db20f5f | 2023-09-09 08:59:23 -0700 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style |
| 5 | # license that can be found in the LICENSE file or at |
| 6 | # https://developers.google.com/open-source/licenses/bsd |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 7 | """Test that Kokoro is using the expected version of python.""" |
| 8 | |
| 9 | import os |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 10 | import sys |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 11 | import unittest |
| 12 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 13 | |
| 14 | class PythonVersionTest(unittest.TestCase): |
| 15 | |
| 16 | def testPython3(self): |
| 17 | """Test that we can import nested import public messages.""" |
| 18 | |
| 19 | exp = os.getenv('KOKORO_PYTHON_VERSION', '') |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 20 | if not exp: |
| 21 | print('No kokoro python version found, skipping check', file=sys.stderr) |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 22 | return |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 23 | self.assertTrue( |
| 24 | sys.version.startswith(exp), |
| 25 | 'Expected Python %s but found Python %s' % (exp, sys.version)) |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 26 | |
| 27 | |
| 28 | if __name__ == '__main__': |
| 29 | unittest.main() |