aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests/QtPrintSupport
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/tests/QtPrintSupport')
-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()