testlib.py 693 B

123456789101112131415161718192021
  1. import os
  2. import subprocess
  3. import yatest.common
  4. def get_python_bin(ver):
  5. res_name = 'EXTERNAL_PYTHON{}_RESOURCE_GLOBAL'.format(ver.replace('.', ''))
  6. gr = yatest.common.global_resources()
  7. if res_name in gr:
  8. bindir = os.path.join(gr[res_name], 'python', 'bin')
  9. if ('python' + ver) in os.listdir(bindir):
  10. return os.path.join(bindir, 'python' + ver)
  11. return os.path.join(bindir, 'python')
  12. raise AssertionError("Resource '{}' is not available: {}".format(res_name, gr))
  13. def check_python_version(version):
  14. ver = subprocess.check_output([get_python_bin(version), '-V'], stderr=subprocess.STDOUT).decode('utf-8')
  15. assert version in ver