aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-09-21 13:31:24 +0200
committerChristian Tismer <tismer@stackless.com>2017-09-25 08:15:10 +0000
commit572a6be53fd39d42288f05ab3c7c9412fc97bc4b (patch)
tree3fc21b45a6d3e16b4f525811273dbfd5c63a8b7c
parentf643be1153275b804e8846b54afccbfef8db43c8 (diff)
Signature: Improve error reporting
It is likely that with Qt 5.9 we get new signature text that is not recognized. This becomes a problem because COIN takes much time. This patch does not stop on the first parser error, but collects all warnings and raises an error at the end. Task-number: PYSIDE-510 Change-Id: I898e0a7a59e8313c115d7ce8160908bf85d4140c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/pyside2/PySide2/support/signature/parser.py7
-rw-r--r--sources/pyside2/tests/pysidetest/signature_test.py11
2 files changed, 8 insertions, 10 deletions
diff --git a/sources/pyside2/PySide2/support/signature/parser.py b/sources/pyside2/PySide2/support/signature/parser.py
index c944fe856..0224095b5 100644
--- a/sources/pyside2/PySide2/support/signature/parser.py
+++ b/sources/pyside2/PySide2/support/signature/parser.py
@@ -48,7 +48,6 @@ import functools
from .mapping import type_map, update_mapping, __dict__ as namespace
_DEBUG = False
-_BREAK_ON_ERROR = False
TYPE_MAP_DOC = """
The type_map variable is central for the signature package.
@@ -165,11 +164,7 @@ def _resolve_value(thing, valtype, line):
UNRECOGNIZED: {!r}
OFFENDING LINE: {!r}
-
- """.format(thing, line),
- RuntimeWarning)
- if _BREAK_ON_ERROR:
- raise RuntimeError
+ """.format(thing, line), RuntimeWarning)
return thing
def _resolve_type(thing, line):
diff --git a/sources/pyside2/tests/pysidetest/signature_test.py b/sources/pyside2/tests/pysidetest/signature_test.py
index 7fa0ab6fc..583b793eb 100644
--- a/sources/pyside2/tests/pysidetest/signature_test.py
+++ b/sources/pyside2/tests/pysidetest/signature_test.py
@@ -45,7 +45,6 @@ import unittest
from collections import OrderedDict
from pprint import pprint
import PySide2
-from PySide2 import *
"""
This test shows that we have over 14500 signatures,
@@ -55,7 +54,6 @@ and that they all can be created.
all_modules = list("PySide2." + x for x in PySide2.__all__)
from PySide2.support.signature import parser, inspect
-parser._BREAK_ON_ERROR = True
_do_print = True if os.isatty(sys.stdout.fileno()) else False
@@ -64,6 +62,7 @@ def dprint(*args, **kw):
print(*args, **kw)
def enum_module(mod_name):
+ __import__(mod_name)
count = 0
module = sys.modules[mod_name]
dprint()
@@ -114,7 +113,11 @@ class PySideSignatureTest(unittest.TestCase):
result = enum_all()
# We omit the number of functions test. This is too vague.
for mod_name, count in result.items():
- pass #self.assertGreaterEqual(count, ref_result[mod_name])
+ pass
+ # If an attribute could not be computed, then we will have a warning
+ # in the warningregistry.
+ if hasattr(parser, "__warningregistry__"):
+ raise RuntimeError("There are errors, see above.")
def testSignatureExist(self):
t1 = type(PySide2.QtCore.QObject.children.__signature__)
@@ -144,7 +147,7 @@ class PySideSignatureTest(unittest.TestCase):
self.assertTrue(ob1 is ob2)
def testModuleIsInitialized(self):
- assert QtWidgets.QApplication.__signature__ is not None
+ assert PySide2.QtWidgets.QApplication.__signature__ is not None
if __name__ == "__main__":
unittest.main()