tests: fix typos, child device subtype, CLI patch path, and deprecation test logic#1677
tests: fix typos, child device subtype, CLI patch path, and deprecation test logic#1677ZeliardM wants to merge 1 commit intopython-kasa:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1677 +/- ##
=======================================
Coverage 93.22% 93.22%
=======================================
Files 157 157
Lines 9815 9815
Branches 1003 1003
=======================================
Hits 9150 9150
Misses 472 472
Partials 193 193 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@rytilahti This PR cleans up a lot of CI testing warnings and errors, the only thing left now is the handling of the fixture files and incomplete fixture file data warning, which I figured was still useful. Let me know if you have any questions. |
There was a problem hiding this comment.
Pull request overview
This PR updates documentation/examples and strengthens test hygiene by ensuring transport/client resources are reliably cleaned up during pytest runs, while also tightening deprecation and discovery CLI test behavior.
Changes:
- Add automatic teardown in multiple transport tests to close created transports and their underlying
aiohttpsessions. - Modernize
IotBulbdoctest examples to use module-based light APIs and align the doctest fixture setup accordingly. - Small correctness/maintenance updates: deprecation-warning expectations, discovery/CLI redaction patch point, child subtype mapping, and GitHub Actions tweaks.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/transports/test_sslaestransport.py | Autouse fixture tracks and closes created SslAesTransport instances after tests. |
| tests/transports/test_linkietransport.py | Autouse fixture tracks and closes LinkieTransportV2 to avoid unclosed HttpClient sessions. |
| tests/transports/test_klaptransport.py | Autouse fixture closes created transports; adds explicit protocol.close() in query test; removes manual session injection. |
| tests/transports/test_aestransport.py | Autouse fixture tracks/closes AesTransport instances to prevent session leaks. |
| tests/test_readme_examples.py | Prepares bulb fixture state (alias + update) so updated iotbulb doctests match expected output. |
| tests/test_httpclient.py | Ensures HttpClient is closed via finally in error-path test. |
| tests/test_discovery.py | Updates assertions to reflect HttpClient internal session behavior and ensures devices/sessions are disconnected/closed. |
| tests/test_deviceconfig.py | Closes aiohttp.ClientSession used in config serialization tests via finally. |
| tests/test_device.py | Refines deprecation-warning expectations for deprecated attributes that warn before raising AttributeError. |
| tests/test_cli.py | Patches redaction at the CLI import site for discover raw testing. |
| kasa/smart/smartchilddevice.py | Adds plug.powerstrip.sub-bulb subtype mapping to DeviceType.Bulb. |
| kasa/iot/iotbulb.py | Updates docstring examples and fixes a minor wording typo (“fetch updated values”). |
| CHANGELOG.md | Fixes typo in deprecated attribute name (valid_temperature_range). |
| .github/workflows/codeql-analysis.yml | Enables CodeQL action file coverage on PRs via env var. |
| .github/actions/setup/action.yaml | Updates pre-commit cache action to actions/cache@v5. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rytilahti
left a comment
There was a problem hiding this comment.
The typo fixes and other maintenance work looks good to me, but to me the try-final pattern looks like it complicates the existing code without much benefits?
|
@rytilahti I'm going to take the comments and see if I can clean the handling up. I agree with the actions piece, we leave it as for now and do another PR later to resolve for all actions. I also agree on the strict typing. I also feel like there needs to be a much larger and broader inspection of tests as a whole, make sure that we are getting the coverages we need for everything and handling everything correctly. Not sure if you want to leave it as is for now and clean up all tests, typing and coverages, in another larger PR. I will look and see if there is a better handling process for the client so that the tests are not having to be patched like this to make sure the client is closed properly. |
|
This PR currently does many different things, so splitting it up would make sense to me. Things like fixing the missing type hints can be done in a single PR, fixing the docstrings in another, etc. This way we can merge the easy ones (CI maintenance, documentation fixes) immediately, and still keep the git history sane (the PR title is used in the git log, so the current one is very non-descriptive and reads like some change log entries "fixed some bugs"..). |
|
@rytilahti Gotcha. I can break this up into a couple of smaller PRs and make them cleaner along the way. Will do! |
ee464a4 to
e2f78d0
Compare
|
@rytilahti Ok, this PR has been updated to just handle the smaller pieces. |
… test logic - Fix CHANGELOG typo: valid_temperate_range -> valid_temperature_range - Add plug.powerstrip.sub-bulb child device type mapping - Narrow discover raw test to patch CLI-level redact path - Fix deprecated attribute test logic for attrs that warn before raising - Update supported_modules -> modules in discovery test
e2f78d0 to
d9a9721
Compare
Summary
Small correctness fixes across tests and source code — foundation cleanup before type annotation PRs.
Changes
valid_temperate_range→valid_temperature_rangeDeviceType.WallSwitchto sub-bulb child type mapping (plug.powerstrip.sub-bulb)redact_datapatch path to match actual module locationdeprecated_warns_before_attribute_errorset to properly handle attributes that emitDeprecationWarningeven when the module isn't present, and fix_test_attributecondition to correctly combineis_expectedandwill_raisesupported_moduleswithmodulesin discovery testkasa.tests.*→tests.*(tests live attests/, notkasa/tests/, soannotation-uncheckedsuppression was never applied)Merge order
This is PR 1 of 9 in the test modernization series. Merge before all other PRs in the series.
Verification