aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-11-30 06:14:24 +0100
committerChristian Tismer <tismer@stackless.com>2017-11-30 10:05:49 +0000
commit7e734adb5d4e02eb1a50052473ac236c14e34862 (patch)
tree3662b62b8f327eeebee2fa25bf906ecd6ad4eadc /sources
parentcd76d677faa1e988b68627919d479752a835efdf (diff)
Fix signature registry on Python2 with .pyc files
There was a problem on Python2 when ci was activated. Because there are .pyc files in the same folder, a leftover .pyc file would be imported and lead to weird results. This problem is not recognized now, but would have effects when we turn on the multiple testing. The intended behavior is that a tests generates an error and a listing once and succeeds for the repeated test runs. This worked in Python3. Now this works the same with Python2. Task-number: PYSIDE-510 Change-Id: Id892715faa8eee1322b28c7e109f3b0b7329f12c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/tests/registry/existence_test.py14
-rw-r--r--sources/pyside2/tests/registry/init_platform.py5
2 files changed, 11 insertions, 8 deletions
diff --git a/sources/pyside2/tests/registry/existence_test.py b/sources/pyside2/tests/registry/existence_test.py
index acdd43570..7627eeab2 100644
--- a/sources/pyside2/tests/registry/existence_test.py
+++ b/sources/pyside2/tests/registry/existence_test.py
@@ -43,12 +43,16 @@ import os
import sys
import unittest
import warnings
-from init_platform import enum_all, generate_all, is_ci, outname
+from init_platform import enum_all, generate_all, is_ci, outname, outpath
from util import isolate_warnings, check_warnings
from PySide2 import *
from PySide2.QtCore import __version__
refmodule_name = outname[:-3] # no .py
+pyc = os.path.splitext(outpath)[0] + ".pyc"
+if os.path.exists(pyc) and not os.path.exists(outname):
+ # on Python2 the pyc file would be imported
+ os.unlink(pyc)
sys.path.insert(0, os.path.dirname(__file__))
try:
@@ -101,12 +105,12 @@ if not have_refmodule and is_ci and version[:2] in tested_versions:
It creates an output listing that can be used to check
the result back in.
"""
- fname = generate_all()
+ generate_all()
sys.stderr.flush()
- print("BEGIN", fname, file=sys.stderr)
- with open(fname) as f:
+ print("BEGIN", outpath, file=sys.stderr)
+ with open(outpath) as f:
print(f.read(), file=sys.stderr)
- print("END", fname, file=sys.stderr)
+ print("END", outpath, file=sys.stderr)
sys.stderr.flush()
raise RuntimeError("This is the initial call. You should check this file in.")
diff --git a/sources/pyside2/tests/registry/init_platform.py b/sources/pyside2/tests/registry/init_platform.py
index 77fff4476..ea8eb2af2 100644
--- a/sources/pyside2/tests/registry/init_platform.py
+++ b/sources/pyside2/tests/registry/init_platform.py
@@ -61,6 +61,7 @@ is_ci = os.environ.get("QTEST_ENVIRONMENT", "") == "ci"
platform = 'linux' if sys.platform.startswith('linux') else sys.platform
outname = "exists_{}_{}{}.py".format(platform, version_id,
"_ci" if is_ci else "")
+outpath = os.path.join(os.path.dirname(__file__), outname)
outfile = None
def xprint(*args, **kw):
@@ -142,9 +143,8 @@ def enum_module(mod_name):
return ret
def generate_all():
- fname = os.path.join(os.path.dirname(__file__), outname)
global outfile
- with open(fname, "w") as outfile:
+ with open(outpath, "w") as outfile:
with open(__file__) as f:
lines = f.readlines()
license_line = next((lno for lno, line in enumerate(lines)
@@ -156,7 +156,6 @@ def generate_all():
for mod_name in all_modules:
enum_module(mod_name)
xprint("# eof")
- return fname
def enum_all():
global outfile