-
-
Notifications
You must be signed in to change notification settings - Fork 574
/
Copy pathpython_toolchain_test.py
35 lines (27 loc) · 1 KB
/
python_toolchain_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
import os
import pathlib
import pprint
import sys
import unittest
from python.runfiles import runfiles
class PythonToolchainTest(unittest.TestCase):
def test_expected_toolchain_matches(self):
expect_version = os.environ["EXPECT_PYTHON_VERSION"]
rf = runfiles.Create()
settings_path = rf.Rlocation(
"rules_python/tests/support/current_build_settings.json"
)
settings = json.loads(pathlib.Path(settings_path).read_text())
expected = "python_{}".format(expect_version.replace(".", "_"))
msg = (
"Expected toolchain not found\n"
+ f"Expected toolchain label to contain: {expected}\n"
+ "Actual build settings:\n"
+ pprint.pformat(settings)
)
self.assertIn(expected, settings["toolchain_label"], msg)
actual = "{v.major}.{v.minor}.{v.micro}".format(v=sys.version_info)
self.assertEqual(actual, expect_version)
if __name__ == "__main__":
unittest.main()