aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-03-20 16:49:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-03-26 09:48:30 +0000
commit4799a56f4ded79257a2cdabe17ce8cd0a674af38 (patch)
treec2ffd3d0598a76b2e7dd28f1875ac1ba300b6179 /sources
parentb09fde6260b255e8b93b0d20a337e701bc940a99 (diff)
Stabilize returnquadruplesofnumbers_test:testQPrinterGetPageMargins()
Loop over the available printers and try to find a PDF printer or similar which allows for setting arbitrary page margins. Failures have been observed with some printer apparently due to invalid values. Task-number: PYSIDE-431 Change-Id: I777e20072834ab1aa7ae3ba7d9b6c83d824aaae1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
index 6e4cfeb63..f6f2490f0 100644
--- a/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
+++ b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
@@ -30,7 +30,7 @@ from __future__ import print_function
import unittest
from PySide2.QtGui import QTextCursor
-from PySide2.QtPrintSupport import QPrinter
+from PySide2.QtPrintSupport import QPrinter, QPrinterInfo
from PySide2.QtWidgets import QLayout, QWidget, QGraphicsLayout, QGraphicsLayoutItem
from helper import UsesQApplication
@@ -81,14 +81,22 @@ class ReturnsQuadruplesOfNumbers(UsesQApplication):
self.assertEqual(obj.selectedTableCells(), (-1, -1, -1, -1))
def testQPrinterGetPageMargins(self):
- # Bug #742
- obj = QPrinter()
+ # Bug #742. Find a printer like PDF/XPS on which arbitrary margins can be set.
+ printer = None
+ for printerInfo in QPrinterInfo.availablePrinters():
+ name = printerInfo.printerName().lower()
+ if "xps" in name or "pdf" in name:
+ printer = QPrinter(printerInfo)
+ break
+ if not printer:
+ printer = QPrinter()
# On macOS the minimum margin of a page is ~12, setting something lower than that will
# actually fail to set all the margins.
values = (15.0, 16.0, 17.0, 18.0, QPrinter.Point)
- obj.setPageMargins(*values)
- print(obj.getPageMargins(QPrinter.Point), values[:-1])
- self.assertTrue(self.compareTuples(obj.getPageMargins(QPrinter.Point), values[:-1]))
+ printer.setPageMargins(*values)
+ actual = printer.getPageMargins(QPrinter.Point)
+ print(printer.printerName(), actual, values[:-1])
+ self.assertTrue(self.compareTuples(actual, values[:-1]))
if __name__ == "__main__":
unittest.main()