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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite mochad unittest to pytest style #42164
Rewrite mochad unittest to pytest style #42164
Conversation
assert await async_setup_component(hass, light.DOMAIN, good_config) | ||
|
||
|
||
@pytest.mark.parametrize("brightness", [32, 256, 64]) |
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.
Why is this parametrized ?
@pytest.mark.parametrize("brightness", [32, 256, 64]) |
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.
Yeah. Parameterizing this test makes no sense. I will remove the test anyway (see below).
|
||
|
||
@pytest.mark.parametrize("brightness", [32, 256, 64]) | ||
async def test_name(light_mock): |
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 test is 馃し I think that we can remove it.
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.
Yes I think we can remove this test. I did keep all the test that have been there before. Did not want to remove any test
assert "fake_light" == light_mock.name | ||
|
||
|
||
@pytest.mark.parametrize( |
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 makes no sense either?
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.
I have combined the 3 old tests that have tested different light levels into one parametrized. The 3 old test have basically tested the same thing with different light levels. If this does not make sense we can replace these tests with more meaningful tests but I did not want to remove any test that was there before
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.
I am also confused why the test returns on with light level 32 and xdim with different light levels. However, this was also the case for the old tests. I would expect a more consistence behavior ..
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.
Interesting, I didn't realize that you could parametrize
stuff in fixtures. TIL!
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.
These tests and the parametrizations don't seem to match up .
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.
Thanks for reviewing. In general I did not want to remove any test that have been there before. Not sure if the tests make that much sense ...
|
||
|
||
@pytest.mark.parametrize("brightness", [32, 256, 64]) | ||
async def test_name(light_mock): |
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.
Yes I think we can remove this test. I did keep all the test that have been there before. Did not want to remove any test
assert "fake_light" == light_mock.name | ||
|
||
|
||
@pytest.mark.parametrize( |
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.
I have combined the 3 old tests that have tested different light levels into one parametrized. The 3 old test have basically tested the same thing with different light levels. If this does not make sense we can replace these tests with more meaningful tests but I did not want to remove any test that was there before
assert await async_setup_component(hass, light.DOMAIN, good_config) | ||
|
||
|
||
@pytest.mark.parametrize("brightness", [32, 256, 64]) |
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.
Yeah. Parameterizing this test makes no sense. I will remove the test anyway (see below).
Hi, I think the confusions comes due to the way how it is parameterized. The brightness in the @pytest.mark.parametrize will affect the brightness in the light_mock fixture. It would be nicer to parameterize the brigthness in the fixture itself however I do not know a good way to combine the expected values (because it will create a test matrix combining each expected with each brightness parameter) |
Breaking change
Proposed change
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast 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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: