8000 Remove obsolete entity count safeguards when using `snapshot_platform` test helper by mib1185 · Pull Request #127736 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove obsolete entity count safeguards when using snapshot_platform test helper #127736

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

Conversation

mib1185
Copy link
Contributor
@mib1185 mib1185 commented Oct 6, 2024

Proposed change

With syrupy==4.7.2 (#127710) not tested snapshots are now recognized, so we do not need to guard against missing entities.

example:

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link
home-assistant bot commented Oct 6, 2024

Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration (axis) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of axis can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign axis Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@home-assistant
Copy link
home-assistant bot commented Oct 6, 2024

Hey there @shaiu, mind taking a look at this pull request as it has been labeled with an integration (israel_rail) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of israel_rail can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign israel_rail Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@home-assistant
Copy link
home-assistant bot commented Oct 6, 2024

Hey there @mammuth, @AaronDavidSchneider, @chemelli74, mind taking a look at this pull request as it has been labeled with an integration (fritz) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of fritz can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign fritz Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@joostlek joostlek changed the title Remove obsolete entity count safeguards when using snap_shotplatform test helper Remove obsolete entity count safeguards when using snapshot_platform test helper Oct 6, 2024
@mib1185 mib1185 merged commit 808d93d into home-assistant:dev Oct 6, 2024
35 checks passed
@mib1185 mib1185 deleted the tests/remove-obsolete-guards-for-entity-count-on-snapshot_platform-tests branch October 6, 2024 13:50
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2024
@epenet
Copy link
Contributor
epenet commented Oct 11, 2024

With syrupy==4.7.2 (#127710) not tested snapshots are now recognized, so we do not need to guard against missing entities.

Sadly unused snapshots are visible - but the CI still passes

pytest tests/components/gardena_bluetooth/test_config_flow.py 
Test session starts (platform: linux, Python 3.12.3, pytest 8.3.3, pytest-sugar 1.0.0)
rootdir: /workspaces/home-assistant-core
configfile: pyproject.toml
plugins: anyio-4.6.0, unordered-0.6.1, typeguard-4.3.0, mock-3.14.0, asyncio-0.24.0, syrupy-4.7.2, aiohttp-1.0.5, cov-5.0.0, xdist-3.6.1, socket-0.7.0, picked-0.5.0, pytest_freezer-0.4.8, timeout-2.3.1, respx-0.21.1, requests-mock-1.12.1, sugar-1.0.0, github-actions-annotate-failures-0.2.0
asyncio: mode=Mode.AUTO, default_loop_scope=function
collected 5 items                                                                                                                                                                                     

 tests/components/gardena_bluetooth/test_config_flow.py ✓✓✓✓✓                                                                                                                           100% ██████████
--------------------------------------------------------------------------------------- snapshot report summary ---------------------------------------------------------------------------------------
10 snapshots passed. 2 snapshots unused.

Re-run pytest with --snapshot-update to delete unused snapshots.

Results (1.09s):
       5 passed

@mib1185
Copy link
Contributor Author
mib1185 commented Oct 11, 2024

cc @joostlek

@joostlek
Copy link
Member

pytest does exit with exit code 1, but apparently that doesn't fail the CI

@epenet
Copy link
Contributor
epenet commented Oct 11, 2024

After investigation - it seems there is an incompatibility with xdist.
See #128162

I don't know if the benefit outweighs the slower runs I don't know if it will be approved.

You may want to monitor that PR and decide if this one should be reverted...

@mib1185
Copy link
Contributor Author
mib1185 commented Oct 11, 2024

mehhh ... that's *piep* 🙈

without multi-threaded pytest it reconizes the unused snapshots and exits with rc 1:

$ pytest tests/components/gardena_bluetooth/test_config_flow.py 
Test session starts (platform: linux, Python 3.12.6, pytest 8.3.3, pytest-sugar 1.0.0)
rootdir: /workspaces/homeassistant-core
configfile: pyproject.toml
plugins: typeguard-4.3.0, mock-3.14.0, sugar-1.0.0, requests-mock-1.12.1, xdist-3.6.1, syrupy-4.7.2, pytest_freezer-0.4.8, cov-5.0.0, timeout-2.3.1, respx-0.21.1, unordered-0.6.1, socket-0.7.0, picked-0.5.0, github-actions-annotate-failures-0.2.0, asyncio-0.24.0, aiohttp-1.0.5, anyio-4.6.0
asyncio: mode=Mode.AUTO, default_loop_scope=function
collected 5 items                                                                                                                                                                                                                                      

 tests/components/gardena_bluetooth/test_config_flow.py ✓✓✓✓✓                                                                                                                                                                            100% ██████████
--------------------------------------------------------------------------------------------------------------- snapshot report summary ----------------------------------------------------------------------------------------------------------------
10 snapshots passed. 2 snapshots unused.

$ echo $?
1

but with multi-threaded pytest, not unused snapshots get recognized, so exists with rc 0

$ pytest -n auto tests/components/gardena_bluetooth/test_config_flow.py
Test session starts (platform: linux, Python 3.12.6, pytest 8.3.3, pytest-sugar 1.0.0)
rootdir: /workspaces/homeassistant-core
configfile: pyproject.toml
plugins: typeguard-4.3.0, mock-3.14.0, sugar-1.0.0, requests-mock-1.12.1, xdist-3.6.1, syrupy-4.7.2, pytest_freezer-0.4.8, cov-5.0
8000
.0, timeout-2.3.1, respx-0.21.1, unordered-0.6.1, socket-0.7.0, picked-0.5.0, github-actions-annotate-failures-0.2.0, asyncio-0.24.0, aiohttp-1.0.5, anyio-4.6.0
asyncio: mode=Mode.AUTO, default_loop_scope=function
6 workers [5 items]     

 tests/components/gardena_bluetooth/test_config_flow.py ✓✓✓✓✓                                                                                                                                                                            100% ██████████

Results (5.56s):
       5 passed
$ echo $?
0

@mib1185
Copy link
Contributor Author
mib1185 commented Oct 11, 2024

even there were efforts spent in the past to make it compatible with xdist -> syrupy-project/syrupy#535

EDIT: it's a documented behavior --> Known Limitations 🙈

@epenet
Copy link
Contributor
epenet commented Oct 12, 2024

I understand why update snapshots would fail.
I'm surprised that unused snapshot causes issue though...

Might be worth revisiting/reopening there

@mib1185
Copy link
Contributor Author
mib1185 commented Oct 15, 2024

PR to revert this one -> #128477

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0