Make minor improvements to the code and fix test on MacOS
This commit is contained in:
@@ -210,12 +210,11 @@ class NPushButton(QPushButton):
|
|||||||
icon: str | None = None, color: str | None = None
|
icon: str | None = None, color: str | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self.setText(text)
|
|
||||||
self.setIconSize(iconSize)
|
|
||||||
self._icon = icon
|
self._icon = icon
|
||||||
self._color = color
|
self._color = color
|
||||||
if icon:
|
self.setText(text)
|
||||||
self.refreshIcon()
|
self.setIconSize(iconSize)
|
||||||
|
self.refreshIcon()
|
||||||
|
|
||||||
def refreshIcon(self) -> None:
|
def refreshIcon(self) -> None:
|
||||||
"""Reload the theme icon."""
|
"""Reload the theme icon."""
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
""" # noqa
|
""" # noqa
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -218,7 +220,8 @@ def testBaseSharedData_GuiAlert():
|
|||||||
# Alert: Info
|
# Alert: Info
|
||||||
alert.setAlertType(_GuiAlert.INFO, False)
|
alert.setAlertType(_GuiAlert.INFO, False)
|
||||||
assert hasattr(alert, "_btnOk")
|
assert hasattr(alert, "_btnOk")
|
||||||
assert alert.windowTitle() == "Information"
|
if sys.platform != "darwin": # Not set on MacOS
|
||||||
|
assert alert.windowTitle() == "Information"
|
||||||
alert._btnOk.click()
|
alert._btnOk.click()
|
||||||
assert alert.finalState is True
|
assert alert.finalState is True
|
||||||
alert._state = False
|
alert._state = False
|
||||||
@@ -226,7 +229,8 @@ def testBaseSharedData_GuiAlert():
|
|||||||
# Alert: Warning
|
# Alert: Warning
|
||||||
alert.setAlertType(_GuiAlert.WARN, False)
|
alert.setAlertType(_GuiAlert.WARN, False)
|
||||||
assert hasattr(alert, "_btnOk")
|
assert hasattr(alert, "_btnOk")
|
||||||
assert alert.windowTitle() == "Warning"
|
if sys.platform != "darwin": # Not set on MacOS
|
||||||
|
assert alert.windowTitle() == "Warning"
|
||||||
alert._btnOk.click()
|
alert._btnOk.click()
|
||||||
assert alert.finalState is True
|
assert alert.finalState is True
|
||||||
alert._state = False
|
alert._state = False
|
||||||
@@ -234,7 +238,8 @@ def testBaseSharedData_GuiAlert():
|
|||||||
# Alert: Error
|
# Alert: Error
|
||||||
alert.setAlertType(_GuiAlert.ERROR, False)
|
alert.setAlertType(_GuiAlert.ERROR, False)
|
||||||
assert hasattr(alert, "_btnOk")
|
assert hasattr(alert, "_btnOk")
|
||||||
assert alert.windowTitle() == "Error"
|
if sys.platform != "darwin": # Not set on MacOS
|
||||||
|
assert alert.windowTitle() == "Error"
|
||||||
alert._btnOk.click()
|
alert._btnOk.click()
|
||||||
assert alert.finalState is True
|
assert alert.finalState is True
|
||||||
alert._state = False
|
alert._state = False
|
||||||
@@ -243,7 +248,8 @@ def testBaseSharedData_GuiAlert():
|
|||||||
alert.setAlertType(_GuiAlert.ASK, True)
|
alert.setAlertType(_GuiAlert.ASK, True)
|
||||||
assert hasattr(alert, "_btnYes")
|
assert hasattr(alert, "_btnYes")
|
||||||
assert hasattr(alert, "_btnNo")
|
assert hasattr(alert, "_btnNo")
|
||||||
assert alert.windowTitle() == "Question"
|
if sys.platform != "darwin": # Not set on MacOS
|
||||||
|
assert alert.windowTitle() == "Question"
|
||||||
alert._btnYes.click()
|
alert._btnYes.click()
|
||||||
assert alert.finalState is True
|
assert alert.finalState is True
|
||||||
alert._btnNo.click()
|
alert._btnNo.click()
|
||||||
|
|||||||
Reference in New Issue
Block a user