GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Mock is_on instead of mutating _info in light_effect tests · python-kasa/python-kasa@f04f085

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tests/smart/modules
    • test_light_effect.py
    • test_light_strip_effect.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/smart/modules/test_light_effect.py‎

Copy file name to clipboardExpand all lines: tests/smart/modules/test_light_effect.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ async def test_light_effect_brightness(
6767
if effect_active: # Set the rule L1 active for testing
6868
light_effect.data["current_rule_id"] = "L1"
6969

70-
# Force device_on so the asserted payload is deterministic across fixtures
70+
# Force is_on=True so the asserted payload is deterministic across fixtures
7171
# (some fixtures' get_device_info has device_on: false).
72-
dev._info["device_on"] = True
72+
mocker.patch.object(
73+
type(dev),
74+
"is_on",
75+
new_callable=mocker.PropertyMock,
76+
return_value=True,
77+
)
7378

7479
await light_module.set_brightness(10)
7580

Collapse file

‎tests/smart/modules/test_light_strip_effect.py‎

Copy file name to clipboardExpand all lines: tests/smart/modules/test_light_strip_effect.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,14 @@ async def test_light_effect_brightness(
8282
return_value=effect_active,
8383
)
8484

85-
# Force device_on so the asserted payload is deterministic across fixtures
85+
# Force is_on=True so the asserted payload is deterministic across fixtures
8686
# (some fixtures' get_device_info has device_on: false).
87-
dev._info["device_on"] = True
87+
mocker.patch.object(
88+
type(dev),
89+
"is_on",
90+
new_callable=mocker.PropertyMock,
91+
return_value=True,
92+
)
8893

8994
await light_module.set_brightness(10)
9095

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.