aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-01-04 21:03:22 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-06 15:34:36 +0000
commit5ea0fde59719866f6eb86a4fe4e33d7f389802c5 (patch)
treedb7305af8d7642b4fddf032ece79dc65d2c95ad4 /sources/pyside6/tests
parentb9a89e1f3c8d0b80cc91bf1d277ead3b7857dabd (diff)
sources: migration from format() to f-strings
This should be the last patch related the usage of f-strings from the 'sources' directory. Change-Id: I0288d720dc4930dee088ca3396a66d1b3ba18f76 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit d9f344fcef6bec04a787f9ea9f4ea94f15eaa26c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r--sources/pyside6/tests/QtCore/bug_PYSIDE-164.py2
-rw-r--r--sources/pyside6/tests/QtCore/multiple_feature_test.py21
-rw-r--r--sources/pyside6/tests/QtCore/qlockfile_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py3
-rw-r--r--sources/pyside6/tests/QtPositioning/positioning.py2
-rw-r--r--sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py4
-rw-r--r--sources/pyside6/tests/init_paths.py2
-rw-r--r--sources/pyside6/tests/pysidetest/all_modules_load_test.py2
-rw-r--r--sources/pyside6/tests/pysidetest/new_inherited_functions_test.py2
-rw-r--r--sources/pyside6/tests/registry/init_platform.py5
-rw-r--r--sources/pyside6/tests/registry/util.py4
-rw-r--r--sources/pyside6/tests/util/processtimer.py4
12 files changed, 26 insertions, 27 deletions
diff --git a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
index a67d2fc75..29097c6d2 100644
--- a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
+++ b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
@@ -51,7 +51,7 @@ class Receiver(QObject):
self.eventloop = eventloop
def receive(self, number):
- print("Received number: %d" % number)
+ print(f"Received number: {number}")
self.eventloop.exit(0)
diff --git a/sources/pyside6/tests/QtCore/multiple_feature_test.py b/sources/pyside6/tests/QtCore/multiple_feature_test.py
index 83e96a2ee..267b4a6cd 100644
--- a/sources/pyside6/tests/QtCore/multiple_feature_test.py
+++ b/sources/pyside6/tests/QtCore/multiple_feature_test.py
@@ -100,19 +100,20 @@ class FeaturesTest(unittest.TestCase):
for bit in range(2, 8):
# We are cheating here, since the functions are in the globals.
- eval(compile(dedent("""
+ bit_pow = 1 << bit
+ eval(compile(dedent(f"""
- def tst_bit{0}(flag, self, bits):
+ def tst_bit{bit}(flag, self, bits):
if flag == 0:
with self.assertRaises(AttributeError):
- QtCore.QCborArray.fake_feature_{1:02x}
+ QtCore.QCborArray.fake_feature_{bit_pow:02x}
with self.assertRaises(KeyError):
- QtCore.QCborArray.__dict__["fake_feature_{1:02x}"]
+ QtCore.QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
else:
- QtCore.QCborArray.fake_feature_{1:02x}
- QtCore.QCborArray.__dict__["fake_feature_{1:02x}"]
+ QtCore.QCborArray.fake_feature_{bit_pow:02x}
+ QtCore.QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
- """).format(bit, 1 << bit), "<string>", "exec"), globals(), edict)
+ """), "<string>", "exec"), globals(), edict)
globals().update(edict)
feature_list = __feature__._really_all_feature_names
func_list = [tst_bit0, tst_bit1, tst_bit2, tst_bit3,
@@ -120,14 +121,14 @@ class FeaturesTest(unittest.TestCase):
for idx in range(0x100):
__feature__.set_selection(0)
- config = "feature_{:02x}".format(idx)
+ config = f"feature_{idx:02x}"
print()
- print("--- Feature Test Config `{}` ---".format(config))
+ print(f"--- Feature Test Config `{config}` ---")
print("Imports:")
for bit in range(8):
if idx & 1 << bit:
feature = feature_list[bit]
- text = "from __feature__ import {}".format(feature)
+ text = f"from __feature__ import {feature}"
print(text)
eval(compile(text, "<string>", "exec"), globals(), edict)
for bit in range(8):
diff --git a/sources/pyside6/tests/QtCore/qlockfile_test.py b/sources/pyside6/tests/QtCore/qlockfile_test.py
index dcd9ecc44..52c517465 100644
--- a/sources/pyside6/tests/QtCore/qlockfile_test.py
+++ b/sources/pyside6/tests/QtCore/qlockfile_test.py
@@ -45,7 +45,7 @@ class TestQMessageAuthenticationCode (unittest.TestCase):
def setUp(self):
pid = QCoreApplication.applicationPid()
- self._fileName = "{}/pqlockfiletest{}.tmp".format(QDir.tempPath(), pid)
+ self._fileName = f"{QDir.tempPath()}/pqlockfiletest{pid}.tmp"
def tearDown(self):
if (os.path.exists(self._fileName)):
diff --git a/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py b/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py
index b9ed2d870..0e27e68d3 100644
--- a/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py
+++ b/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py
@@ -39,8 +39,7 @@ from PySide6.QtCore import QOperatingSystemVersion
class TestQOperatingSystemVersion(unittest.TestCase):
def test(self):
ov = QOperatingSystemVersion.current()
- name = "{} v{}.{}.{}".format(ov.name(), ov.majorVersion(),
- ov.minorVersion(), ov.microVersion())
+ name = f"{ov.name()} v{ov.majorVersion()}.{ov.minorVersion()}.{ov.microVersion()}"
print(name)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtPositioning/positioning.py b/sources/pyside6/tests/QtPositioning/positioning.py
index 7edcefcd8..70480e61d 100644
--- a/sources/pyside6/tests/QtPositioning/positioning.py
+++ b/sources/pyside6/tests/QtPositioning/positioning.py
@@ -44,7 +44,7 @@ class QPositioningTestCase(unittest.TestCase):
source = QGeoPositionInfoSource.createDefaultSource(None)
self.assertTrue(source is not None)
name = source.sourceName()
- print('QtPositioning source: {}'.format(name))
+ print(f"QtPositioning source: {name}")
self.assertTrue(name)
if __name__ == "__main__":
diff --git a/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py b/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
index b4b5267e9..3d15e948c 100644
--- a/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
+++ b/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
@@ -43,8 +43,8 @@ from PySide6.QtSvgWidgets import QSvgWidget
class QSvgWidgetTest(unittest.TestCase):
def testLoad(self):
- dir = os.path.dirname(__file__)
- tigerPath = QDir.cleanPath("{}/../QtSvg/tiger.svg".format(dir))
+ directory = os.path.dirname(__file__)
+ tigerPath = QDir.cleanPath(f"{directory}/../QtSvg/tiger.svg")
self.assertTrue(QFileInfo.exists(tigerPath))
app = QApplication([])
diff --git a/sources/pyside6/tests/init_paths.py b/sources/pyside6/tests/init_paths.py
index 0230ca99d..64b4f8791 100644
--- a/sources/pyside6/tests/init_paths.py
+++ b/sources/pyside6/tests/init_paths.py
@@ -54,7 +54,7 @@ def _get_qt_dir():
break
if not result:
raise ValueError('Unable to locate Qt. Please set the environment variable QT_DIR')
- print('Qt as determined by path search: {}'.format(result), file=sys.stderr)
+ print(f"Qt as determined by path search: {result}", file=sys.stderr)
return result
diff --git a/sources/pyside6/tests/pysidetest/all_modules_load_test.py b/sources/pyside6/tests/pysidetest/all_modules_load_test.py
index 85807b825..08a78aa40 100644
--- a/sources/pyside6/tests/pysidetest/all_modules_load_test.py
+++ b/sources/pyside6/tests/pysidetest/all_modules_load_test.py
@@ -45,7 +45,7 @@ class AllModulesImportTest(unittest.TestCase):
def testAllModulesCanImport(self):
# would also work: exec("from PySide6 import *")
for name in PySide6.__all__:
- exec("import PySide6.{}".format(name))
+ exec(f"import PySide6.{name}")
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
index 5e342182a..7a8e03fe8 100644
--- a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
+++ b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
@@ -122,7 +122,7 @@ class MainTest(unittest.TestCase):
"""
for app in "QtWidgets.QApplication", "QtGui.QGuiApplication", "QtCore.QCoreApplication":
try:
- exec("qApp = PySide6.{0}([]) or PySide6.{0}.instance()".format(app))
+ exec(f"qApp = PySide6.{app}([]) or PySide6.{app}.instance()")
break
except AttributeError:
continue
diff --git a/sources/pyside6/tests/registry/init_platform.py b/sources/pyside6/tests/registry/init_platform.py
index bceb80190..90a7a21a8 100644
--- a/sources/pyside6/tests/registry/init_platform.py
+++ b/sources/pyside6/tests/registry/init_platform.py
@@ -85,7 +85,7 @@ elif os.path.exists(history_dir):
try:
all_build_dir = f_contents_split[0]
except IndexError:
- print("Error: can't find the build dir in the given file '{}'".format(fpath))
+ print(f"Error: can't find the build dir in the given file '{fpath}'")
sys.exit(1)
else:
print(dedent("""
@@ -244,8 +244,7 @@ def generate_all():
def __main__():
- print("+++ generating {}. You should probably check this file in."
- .format(get_refpath()))
+ print(f"+++ generating {get_refpath()}. You should probably check this file in.")
generate_all()
diff --git a/sources/pyside6/tests/registry/util.py b/sources/pyside6/tests/registry/util.py
index cbbec2383..dba4b5c0a 100644
--- a/sources/pyside6/tests/registry/util.py
+++ b/sources/pyside6/tests/registry/util.py
@@ -147,8 +147,8 @@ def qt_version():
# Format a registry file name for version.
def _registry_filename(version, use_ci_module):
- name = "exists_{}_{}_{}_{}{}.py".format(platform_name,
- version[0], version[1], version[2], "_ci" if use_ci_module else "")
+ ext_ci = "_ci" if use_ci_module else ""
+ name = f"exists_{platform_name}_{version[0]}_{version[1]}_{version[2]}{ext_ci}.py"
return os.path.join(os.path.dirname(__file__), name)
# Return the expected registry file name.
diff --git a/sources/pyside6/tests/util/processtimer.py b/sources/pyside6/tests/util/processtimer.py
index 74fe93648..067f1d29c 100644
--- a/sources/pyside6/tests/util/processtimer.py
+++ b/sources/pyside6/tests/util/processtimer.py
@@ -67,11 +67,11 @@ if __name__ == "__main__":
try:
t.waitfor()
except TimeoutException:
- print("timeout - PID: %d" % (t.proc.pid))
+ print(f"timeout - PID: {t.proc.pid}")
#TODO: detect SO and kill accordingly
#Linux
os.kill(t.proc.pid, 9)
#Windows (not tested)
#subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True)
- print("exit code: %d" % (t.proc.poll()))
+ print(f"exit code: {t.proc.poll()}")