Skip to content

Commit 58dc331

Browse files
Jaime ResanoFriedemannKleint
Jaime Resano
authored andcommitted
pyproject.toml: 3. Add pyside6-project tests for pyproject.toml changes
This patch adds tests for the pyside6-project CLI tool to validate the pyproject.toml changes. The tests ensure that the existing behavior is preserved and that the new features work as expected. Task-number: PYSIDE-2714 Change-Id: I096188c1d6d931a3970787f2906b83d2a987f4ed Reviewed-by: Cristian Maureira-Fredes <[email protected]>
1 parent 545ca79 commit 58dc331

26 files changed

+525
-56
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[project]
2+
name = "Drumpad"
3+
4+
[tool.pyside6-project]
5+
files = ["autogen/settings.py", "main.py"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["mainwindow.py", "my_widget.py", "folder/file_in_folder.py", "main.py", "subproject/subproject.pyproject"]
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
from PySide6.QtWidgets import QLabel
4+
5+
6+
class LabelInFolder(QLabel):
7+
def __init__(self):
8+
super().__init__()
9+
self.setText("Label in folder")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
import os
4+
5+
from mainwindow import MainWindow
6+
from PySide6.QtWidgets import QApplication
7+
import sys
8+
9+
10+
def main():
11+
app = QApplication(sys.argv)
12+
window = MainWindow()
13+
if os.getenv("PYSIDE_TESTING"):
14+
return 0
15+
window.show()
16+
return app.exec()
17+
18+
19+
if __name__ == "__main__":
20+
sys.exit(main())
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
from PySide6.QtWidgets import QMainWindow, QWidget, QVBoxLayout
4+
from folder.label_in_folder import LabelInFolder
5+
from subproject.subproject_button import SubprojectButton
6+
7+
8+
class MainWindow(QMainWindow):
9+
def __init__(self, parent=None):
10+
super().__init__(parent)
11+
self.setWindowTitle("Main Window")
12+
13+
self.central_layout = QVBoxLayout()
14+
self.central_widget = QWidget()
15+
self.setCentralWidget(self.central_widget)
16+
self.central_widget.setLayout(self.central_layout)
17+
18+
self.label_in_folder = LabelInFolder()
19+
self.central_layout.addWidget(self.label_in_folder)
20+
21+
self.subproject_button = SubprojectButton()
22+
self.central_layout.addWidget(self.subproject_button)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[project]
2+
name = "example_project"
3+
4+
[tool.pyside6-project]
5+
files = ["folder/file_in_folder.py", "main.py", "mainwindow.py", "my_widget.py", "subproject/subproject.pyproject"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[project]
2+
name = "subproject"
3+
4+
[tool.pyside6-project]
5+
files = ["subproject_button.py"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["subproject_button.py"]
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
from PySide6.QtWidgets import QPushButton, QApplication
4+
import sys
5+
6+
7+
class SubprojectButton(QPushButton):
8+
def __init__(self):
9+
super().__init__()
10+
self.setText("Subproject button")
11+
12+
13+
if __name__ == "__main__":
14+
app = QApplication(sys.argv)
15+
button = SubprojectButton()
16+
button.show()
17+
sys.exit(app.exec())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["zzz.py", "main.py"]
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "my_project"
3+
version = "0.1.0"
4+
description = "A sample Python project"
5+
authors = [
6+
{ name = "John Doe", email = "[email protected]" },
7+
]
8+
optional-dependencies = { dev = ["pytest", "black"], docs = ["sphinx"] }
9+
10+
# Comment
11+
12+
[tool.black]
13+
line-length = 88
14+
target-version = ["py38"]
15+
16+
# Another comment
17+
18+
[tool.pyside6-project]
19+
files = ["main.py", "zzz.py"]
20+
[build-system]
21+
requires = ["setuptools >=42"]
22+
build-backend = "setuptools.build_meta"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[project]
2+
name = "my_project"
3+
version = "0.1.0"
4+
description = "A sample Python project"
5+
authors = [
6+
{ name = "John Doe", email = "[email protected]" },
7+
]
8+
optional-dependencies = { dev = ["pytest", "black"], docs = ["sphinx"] }
9+
10+
# Comment
11+
12+
[tool.black]
13+
line-length = 88
14+
target-version = ["py38"]
15+
16+
# Another comment
17+
18+
[build-system]
19+
requires = ["setuptools >=42"]
20+
build-backend = "setuptools.build_meta"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (C) 2025 The Qt Company Ltd.
2+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["main.py", 33]
3+
}

sources/pyside6/tests/tools/pyside6-project/invalid_pyproject/main.py

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
this is not a valid pyproject.toml file
2+
because it does not have a valid toml structure
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["main.py"]
3+
}

sources/pyside6/tests/tools/pyside6-project/multiple_pyproject/common_file.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[project]
2+
name = "multiple_pyproject"
3+
4+
[tool.pyside6-project]
5+
files = ["common_file.py", "file1.py", "file2.py"]

sources/pyside6/tests/tools/pyside6-project/multiple_pyproject/file1.py

Whitespace-only changes.

sources/pyside6/tests/tools/pyside6-project/multiple_pyproject/file2.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["file1.py", "common_file.py"]
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": ["common_file.py", "file2.py"]
3+
}

0 commit comments

Comments
 (0)