lint: ruff cleanup pass across bal/ and tests/
- Sort imports and fix pyproject ruff config (per-file ignores for intentional Qt/core exceptions) - Mark Heirs.validate_* helpers as @staticmethod - Clean up dead code, rename shadowing vars, use raise ... from - Add AGENTS.md with env/lint/test/release guidance
This commit is contained in:
@@ -8,12 +8,13 @@ Run:
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, __file__.rsplit("/", 2)[0])
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QGridLayout, QLabel, QWidget
|
||||
from PyQt6.QtWidgets import QApplication, QGridLayout, QLabel
|
||||
|
||||
# Import the module itself, not via "from .common import *"
|
||||
import bal.gui.qt.common as C
|
||||
import bal.gui.qt.common as common
|
||||
|
||||
_app = QApplication.instance() or QApplication(sys.argv)
|
||||
|
||||
@@ -23,18 +24,18 @@ _app = QApplication.instance() or QApplication(sys.argv)
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_shown_cv_default():
|
||||
cv = C.shown_cv(True)
|
||||
cv = common.shown_cv(True)
|
||||
assert cv.get() is True
|
||||
|
||||
|
||||
def test_shown_cv_set():
|
||||
cv = C.shown_cv(True)
|
||||
cv = common.shown_cv(True)
|
||||
cv.set(False)
|
||||
assert cv.get() is False
|
||||
|
||||
|
||||
def test_shown_cv_roundtrip():
|
||||
cv = C.shown_cv(False)
|
||||
cv = common.shown_cv(False)
|
||||
assert cv.get() is False
|
||||
cv.set(True)
|
||||
assert cv.get() is True
|
||||
@@ -47,19 +48,19 @@ def test_shown_cv_roundtrip():
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_check_alive_error_default():
|
||||
err = C.CheckAliveError(1000000)
|
||||
err = common.CheckAliveError(1000000)
|
||||
assert err.timestamp_to_check == 1000000
|
||||
|
||||
|
||||
def test_check_alive_error_str():
|
||||
err = C.CheckAliveError(1000000)
|
||||
err = common.CheckAliveError(1000000)
|
||||
s = str(err)
|
||||
assert "Check alive expired" in s
|
||||
assert "1970" in s
|
||||
|
||||
|
||||
def test_check_alive_error_subclass():
|
||||
assert issubclass(C.CheckAliveError, Exception)
|
||||
assert issubclass(common.CheckAliveError, Exception)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
@@ -68,17 +69,15 @@ def test_check_alive_error_subclass():
|
||||
|
||||
def test_add_widget():
|
||||
grid = QGridLayout()
|
||||
parent = QWidget()
|
||||
label = QLabel("test")
|
||||
C.add_widget(grid, "Label", label, 0, "Help text")
|
||||
common.add_widget(grid, "Label", label, 0, "Help text")
|
||||
assert grid.count() == 3 # label + widget + help button
|
||||
|
||||
|
||||
def test_add_widget_multiple_rows():
|
||||
grid = QGridLayout()
|
||||
parent = QWidget()
|
||||
C.add_widget(grid, "A", QLabel("a"), 0, "help_a")
|
||||
C.add_widget(grid, "B", QLabel("b"), 1, "help_b")
|
||||
common.add_widget(grid, "A", QLabel("a"), 0, "help_a")
|
||||
common.add_widget(grid, "B", QLabel("b"), 1, "help_b")
|
||||
assert grid.count() == 6
|
||||
|
||||
|
||||
@@ -87,7 +86,7 @@ def test_add_widget_multiple_rows():
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_log_error_no_window():
|
||||
C.log_error((Exception, Exception("test"), None))
|
||||
common.log_error((Exception, Exception("test"), None))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
Reference in New Issue
Block a user