28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
import ast
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).parents[1]
|
|
|
|
|
|
class StartupRegression0417Tests(unittest.TestCase):
|
|
def test_themed_icon_accepts_variadic_fallbacks(self):
|
|
source = (ROOT / "src/librenet_scanner/ui_icons.py").read_text(encoding="utf-8")
|
|
tree = ast.parse(source)
|
|
fn = next(node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name == "themed_icon")
|
|
self.assertIsNotNone(fn.args.vararg, "themed_icon doit accepter plusieurs fallbacks")
|
|
self.assertEqual(fn.args.vararg.arg, "fallbacks")
|
|
|
|
def test_forget_identifications_menu_can_supply_three_theme_candidates(self):
|
|
source = (ROOT / "src/librenet_scanner/ui.py").read_text(encoding="utf-8")
|
|
self.assertIn('themed_icon("edit-delete", "edit-clear-history", "user-trash")', source)
|
|
# The regression in 0.4.16 was exactly a 3-positional-argument call.
|
|
# Variadic themed_icon must therefore remain compatible with it.
|
|
icon_source = (ROOT / "src/librenet_scanner/ui_icons.py").read_text(encoding="utf-8")
|
|
self.assertIn('def themed_icon(name: str, *fallbacks: str)', icon_source)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|