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/existence_test.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/existence_test.py')
-rw-r--r-- | sources/pyside2/tests/registry/existence_test.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/sources/pyside2/tests/registry/existence_test.py b/sources/pyside2/tests/registry/existence_test.py index e7cadd54d..8f3c568a3 100644 --- a/sources/pyside2/tests/registry/existence_test.py +++ b/sources/pyside2/tests/registry/existence_test.py @@ -43,20 +43,28 @@ import os import sys import unittest from textwrap import dedent -from init_platform import enum_all, generate_all, is_ci, module, refpath +from init_platform import (enum_all, generate_all, is_ci, + getEffectiveRefPath, getRefPath, qtVersion) from util import isolate_warnings, check_warnings, suppress_warnings, warn from PySide2 import * -from PySide2.QtCore import __version__ -pyc = os.path.splitext(refpath)[0] + ".pyc" -if os.path.exists(pyc) and not os.path.exists(refpath): +refPath = getRefPath() +effectiveRefPath = getEffectiveRefPath() +effectiveRefPathRoot = os.path.splitext(effectiveRefPath)[0] +pyc = effectiveRefPathRoot + ".pyc" +if os.path.exists(pyc) and not os.path.exists(effectiveRefPath): # on Python2 the pyc file would be imported os.unlink(pyc) +module = os.path.basename(effectiveRefPathRoot) -home_dir = refpath +if refPath != effectiveRefPath: + print("*** Falling back to ", effectiveRefPath, " since expected ", + refPath, " does not exist") + +home_dir = effectiveRefPath for _ in "abcde": home_dir = os.path.dirname(home_dir) -shortpath = os.path.relpath(refpath, home_dir) +shortpath = os.path.relpath(effectiveRefPath, home_dir) try: exec("import {} as sig_exists".format(module)) print("found:", shortpath) @@ -66,11 +74,11 @@ except ImportError: have_refmodule = False except SyntaxError: print("*** not a python file, removed:", shortpath) - os.unlink(refpath) + os.unlink(effectiveRefPath) have_refmodule = False if have_refmodule and not hasattr(sig_exists, "dict"): print("*** wrong module without 'dict', removed:", shortpath) - os.unlink(refpath) + os.unlink(effectiveRefPath) have_refmodule = False @@ -112,10 +120,9 @@ class TestSignaturesExists(unittest.TestCase): warn("multi-signature count mismatch: '{}'".format(key)) self.assertTrue(check_warnings()) -version = tuple(map(int, __version__.split("."))) tested_versions = (5, 6), (5, 9), (5, 11) -if not have_refmodule and is_ci and version[:2] in tested_versions: +if not have_refmodule and is_ci and qtVersion()[:2] in tested_versions: class TestFor_CI_Init(unittest.TestCase): """ This helper class generates the reference file for CI. @@ -124,16 +131,16 @@ if not have_refmodule and is_ci and version[:2] in tested_versions: """ generate_all() sys.stderr.flush() - print("BEGIN_FILE", shortpath, file=sys.stderr) - with open(refpath) as f: + print("BEGIN_FILE", refPath, file=sys.stderr) + with open(refPath) as f: print(f.read(), file=sys.stderr) - print("END_FILE", shortpath, file=sys.stderr) + print("END_FILE", refPath, file=sys.stderr) sys.stderr.flush() raise RuntimeError(dedent(""" {line} ** This is the initial call. You should check this file in: ** {} - **""").format(shortpath, line=79 * "*")) + **""").format(refPath, line=79 * "*")) if __name__ == '__main__': unittest.main() |