Refactor tests
This commit is contained in:
parent
ebb0fd6e11
commit
a29fc9423e
10 changed files with 1069 additions and 121 deletions
55
tests/test_toolbar_styles.py
Normal file
55
tests/test_toolbar_styles.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
from PySide6.QtGui import QTextCursor, QFont
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtTest import QTest
|
||||
|
||||
|
||||
def test_toggle_basic_char_styles(open_window, qtbot):
|
||||
win = open_window
|
||||
win.editor.setPlainText("style")
|
||||
c = win.editor.textCursor()
|
||||
c.select(QTextCursor.Document)
|
||||
win.editor.setTextCursor(c)
|
||||
win.toolBar.actBold.trigger()
|
||||
assert win.editor.currentCharFormat().fontWeight() == QFont.Weight.Bold
|
||||
win.toolBar.actItalic.trigger()
|
||||
assert win.editor.currentCharFormat().fontItalic() is True
|
||||
win.toolBar.actUnderline.trigger()
|
||||
assert win.editor.currentCharFormat().fontUnderline() is True
|
||||
win.toolBar.actStrike.trigger()
|
||||
assert win.editor.currentCharFormat().fontStrikeOut() is True
|
||||
|
||||
|
||||
def test_headings_lists_and_alignment(open_window, qtbot):
|
||||
win = open_window
|
||||
win.editor.setPlainText("Heading\nSecond line")
|
||||
c = win.editor.textCursor()
|
||||
c.select(QTextCursor.LineUnderCursor)
|
||||
win.editor.setTextCursor(c)
|
||||
|
||||
sizes = []
|
||||
for attr in ("actH1", "actH2", "actH3"):
|
||||
if hasattr(win.toolBar, attr):
|
||||
getattr(win.toolBar, attr).trigger()
|
||||
QTest.qWait(45) # let the format settle to avoid segfaults on some styles
|
||||
sizes.append(win.editor.currentCharFormat().fontPointSize())
|
||||
assert len(sizes) >= 2 and all(
|
||||
a > b for a, b in zip(sizes, sizes[1:])
|
||||
), f"Heading sizes not decreasing: {sizes}"
|
||||
|
||||
win.toolBar.actCode.trigger()
|
||||
QTest.qWait(45)
|
||||
|
||||
win.toolBar.actBullets.trigger()
|
||||
QTest.qWait(45)
|
||||
win.toolBar.actNumbers.trigger()
|
||||
QTest.qWait(45)
|
||||
|
||||
win.toolBar.actAlignC.trigger()
|
||||
QTest.qWait(45)
|
||||
assert int(win.editor.alignment()) & int(Qt.AlignHCenter)
|
||||
win.toolBar.actAlignR.trigger()
|
||||
QTest.qWait(45)
|
||||
assert int(win.editor.alignment()) & int(Qt.AlignRight)
|
||||
win.toolBar.actAlignL.trigger()
|
||||
QTest.qWait(45)
|
||||
assert int(win.editor.alignment()) & int(Qt.AlignLeft)
|
||||
Loading…
Add table
Add a link
Reference in a new issue