summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-07-05 14:40:03 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-07-07 09:56:23 +0200
commitacb4e247fdf42af633b03e86da4eaf771f66c125 (patch)
treea6ec788cd7ec0ca9a726fbd4582a8141741a6f7a /tests
parenta2d13a6259ecdafa056efcd66e9398b700641620 (diff)
lupdate: Improve indentation calculation for Python code
Introduce a "def" token for function definitions and perform the calculation of the indentation as well as the pushing/popping of class contexts only for "class" and "def". Fixes: PYSIDE-2379 Pick-to: 6.6 6.5 Change-Id: Ic59af41afbb5ca602c110c3f25dfc953000467d8 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsepython/main.py10
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result13
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py b/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py
index 6375ff4da..e2bf9ac93 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py
+++ b/tests/auto/linguist/lupdate/testdata/good/parsepython/main.py
@@ -5,10 +5,10 @@ from PySide6.QtCore import (QItemSelection, QLibraryInfo, QLocale, QTranslator,
Qt, Slot)
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QListWidget,
QMainWindow, QWidget)
-
-
import linguist_rc
+""""
+ Misleading indentation (5) for PYSIDE-2379"""
class Window(QMainWindow):
def __init__(self):
@@ -66,6 +66,12 @@ class Window(QMainWindow):
"THIS SHOULD NOT WORK"
)
+ class NestedClass:
+ def foo(self):
+ msg = self.tr("Nested Message")
+
+ def window_method(self): # PYSIDE-2379, Don't put this into NestedClass
+ msg = self.tr("Window Message")
if __name__ == '__main__':
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result
index f081bc23a..658485339 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsepython/project.ts.result
@@ -38,6 +38,14 @@
</message>
</context>
<context>
+ <name>NestedClass</name>
+ <message>
+ <location filename="main.py" line="73"/>
+ <source>Nested Message</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>Window</name>
<message>
<location filename="main.py" line="17"/>
@@ -72,5 +80,10 @@
<numerusform></numerusform>
</translation>
</message>
+ <message>
+ <location filename="main.py" line="77"/>
+ <source>Window Message</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>