Skip to content

Commit 408f586

Browse files
committed
Add misc tests
1 parent 70dd77b commit 408f586

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

tests/qlayout.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
from PySide6.QtWidgets import QGridLayout, QHBoxLayout, QVBoxLayout, QLayout
1+
from typing_extensions import override
2+
from PySide6.QtWidgets import QGridLayout, QHBoxLayout, QVBoxLayout, QLayout, QLayoutItem
23

34
a = QGridLayout(parent=None)
45
b = QHBoxLayout(parent=None)
56
c = QVBoxLayout(parent=None)
7+
8+
class TestLayout(QLayout):
9+
# These can return None
10+
@override
11+
def itemAt(self, index: int) -> 'QLayoutItem | None':
12+
return super().itemAt(index)
13+
14+
@override
15+
def takeAt(self, index: int) -> 'QLayoutItem | None':
16+
return super().takeAt(index)
17+
18+
assert a.itemAt(0) is None
19+
assert a.takeAt(0) is None

tests/qpixmap.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
from PySide6.QtCore import Qt
1+
from PySide6.QtCore import QByteArray, Qt
22
from PySide6.QtGui import QPixmap
33

44
emptyPixmap = QPixmap(16, 16)
55
emptyPixmap.fill(Qt.GlobalColor.transparent)
66
emptyPixmap.fill('white')
77
emptyPixmap.fill(0xFFFFFF)
8+
9+
# Should accept str for format
10+
worlds_smallest_png = QByteArray.fromBase64(b"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVR4AWNgAAAAAgABc3UBGAAAAABJRU5ErkJggg==")
11+
load_pixmap = QPixmap()
12+
load_pixmap.loadFromData(worlds_smallest_png, "PNG")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from PySide6.QtGui import QRegularExpressionValidator, QValidator
2+
3+
4+
v = QRegularExpressionValidator()
5+
6+
valid_info: tuple[QValidator.State, str, int] = v.validate("", 0)
7+
assert isinstance(valid_info, tuple)
8+
assert isinstance(valid_info[0], QValidator.State)
9+
assert isinstance(valid_info[1], str)
10+
assert isinstance(valid_info[2], int)

tests/qtreewidget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
# default type returned by topLevelItem() should allow None value
1414
topItem = None
1515

16+
t.setCurrentItem(None)
17+
current_item = t.currentItem()
18+
current_item = None

0 commit comments

Comments
 (0)