summaryrefslogtreecommitdiffstats
path: root/build/platform/python/tests/testlib.py
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/platform/python/tests/testlib.py
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/platform/python/tests/testlib.py')
-rw-r--r--build/platform/python/tests/testlib.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/build/platform/python/tests/testlib.py b/build/platform/python/tests/testlib.py
new file mode 100644
index 00000000000..d12f2815d48
--- /dev/null
+++ b/build/platform/python/tests/testlib.py
@@ -0,0 +1,21 @@
+import os
+import subprocess
+
+import yatest.common
+
+
+def get_python_bin(ver):
+ res_name = 'EXTERNAL_PYTHON{}_RESOURCE_GLOBAL'.format(ver.replace('.', ''))
+ gr = yatest.common.global_resources()
+ if res_name in gr:
+ bindir = os.path.join(gr[res_name], 'python', 'bin')
+ if ('python' + ver) in os.listdir(bindir):
+ return os.path.join(bindir, 'python' + ver)
+ return os.path.join(bindir, 'python')
+
+ raise AssertionError("Resource '{}' is not available: {}".format(res_name, gr))
+
+
+def check_python_version(version):
+ ver = subprocess.check_output([get_python_bin(version), '-V'], stderr=subprocess.STDOUT).decode('utf-8')
+ assert version in ver