test_common.py 938 B

12345678910111213141516171819202122232425262728293031
  1. import subprocess
  2. import pytest
  3. from build.platform.python.tests import testlib
  4. PYTHON_VERSIONS = ["2.7", "3.4", "3.5", "3.6"] # 3.7, 3.8 are not runnable
  5. @pytest.mark.parametrize("pyver", PYTHON_VERSIONS)
  6. def test_version_matched(pyver):
  7. testlib.check_python_version(pyver)
  8. @pytest.mark.parametrize("pyver", PYTHON_VERSIONS)
  9. def test_python_max_unicode_bytes(pyver):
  10. cmd = [testlib.get_python_bin(pyver), '-c', 'import sys; print(sys.maxunicode)']
  11. maxunicode = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode('utf-8')
  12. assert int(maxunicode) > 65535, "Found UCS2 build"
  13. @pytest.mark.parametrize("pyver", PYTHON_VERSIONS)
  14. def test_python_imports(pyver):
  15. imports = {
  16. "2.7": ['pkg_resources'],
  17. "3.4": [],
  18. "3.5": ['pkg_resources'],
  19. "3.6": [],
  20. }
  21. for imp in imports[pyver]:
  22. subprocess.check_call([testlib.get_python_bin(pyver), '-c', 'import ' + imp])