-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix synology_dsm test side effects #114722
Conversation
Hey there @hacf-fr, @Quentame, @mib1185, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
tempfile.tempdir = tmp_path | ||
result = await view.get(request, "mocked_syno_dsm_entry", "10_1298753/filename.jpg") | ||
assert isinstance(result, web.Response) | ||
with patch.object(tempfile, "tempdir", tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird. Does this test actually save a file in a temporary directory? The library should just be patched instead and it's enough to assert that the library is called correctly. And of course we shouldn't create the view directly in the test but use our client to make a request to the server endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue was that the test set the tempdir globally with tempfile.tempdir = tmp_path
.
As I'm not familiar with the integration I fixed it in the least invasive way, and that was to patch it instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. This was just a side note.
Breaking change
Proposed change
Fix the side effects introduced by synology_dsm by using patch instead of setting
tempdir
globallyBefore this fix the shell_commands tests would fail as they expect
tempdir
to beNone
Can be reproduced with
pytest tests/components/synology_dsm/test_media_source.py tests/components/shell_command/test_init.py
Noticed in https://github.com/home-assistant/core/actions/runs/8535313705/job/23382222724
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: