diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-20 15:10:24 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-21 11:48:01 +0000 |
commit | cd1037060e0cbc263e601fb67fbd40d85c8801a1 (patch) | |
tree | b66438de1f83059a15353e1d96ac0b783b8d2021 /sources/pyside2/tests/registry/init_platform.py | |
parent | 8d8437517a7618aab502d3d0f70c9ab5840d9993 (diff) |
Signature existence tests: Fall back to previous patch releases
In case the reference file for a given patch release does not
exist, fall back to a previous one.
Replace variables in the init_platform module by functions
getEffectiveRefPath(), getRefPath().
Task-number: PYSIDE-510
Change-Id: I208f4618be6e20be5023938850ca0eacc43b0101
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/tests/registry/init_platform.py')
-rw-r--r-- | sources/pyside2/tests/registry/init_platform.py | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/sources/pyside2/tests/registry/init_platform.py b/sources/pyside2/tests/registry/init_platform.py index 2a0b66e06..ffe6e22fc 100644 --- a/sources/pyside2/tests/registry/init_platform.py +++ b/sources/pyside2/tests/registry/init_platform.py @@ -57,16 +57,42 @@ all_modules = list("PySide2." + x for x in PySide2.__all__) from PySide2.support.signature import inspect from PySide2.QtCore import __version__ -version_id = __version__.replace(".", "_") is_py3 = sys.version_info[0] == 3 is_ci = os.environ.get("QTEST_ENVIRONMENT", "") == "ci" # Python2 legacy: Correct 'linux2' to 'linux', recommended way. platform = 'linux' if sys.platform.startswith('linux') else sys.platform -module = "exists_{}_{}{}".format(platform, version_id, "_ci" if is_ci else "") -refpath = os.path.join(os.path.dirname(__file__), module + ".py") # Make sure not to get .pyc in Python2. sourcepath = os.path.splitext(__file__)[0] + ".py" +def qtVersion(): + return tuple(map(int, __version__.split("."))) + +# Format a registry file name for version +def _registryFileName(version): + name = "exists_{}_{}_{}_{}{}.py".format(platform, + version[0], version[1], version[2], "_ci" if is_ci else "") + return os.path.join(os.path.dirname(__file__), name) + +# Return the expected registry file name +def getRefPath(): + return _registryFileName(qtVersion()) + +# Return the registry file name, either that of the current +# version or fall back to a previous patch release +def getEffectiveRefPath(): + refpath = getRefPath() + if os.path.exists(refpath): + return refpath + version = qtVersion() + majorVersion = version[0] + minorVersion = version[1] + patchVersion = version[2] + while patchVersion >= 0: + file = _registryFileName((majorVersion, minorVersion, patchVersion)) + if os.path.exists(file): + return file + patchVersion = patchVersion - 1 + return refpath class Formatter(object): """ @@ -203,7 +229,7 @@ def enum_all(): return ret def generate_all(): - with open(refpath, "w") as outfile, open(sourcepath) as f: + with open(refPath(), "w") as outfile, open(sourcepath) as f: fmt = Formatter(outfile) enu = SimplifyingEnumerator(fmt) lines = f.readlines() |