-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve (and fix some) test finalization #838
Conversation
7dc61e9
to
afe0ad3
Compare
They are already covered by flake8. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Makes the code a bit less verbose, and the types are very well known, so the origin is obvious. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
afe0ad3
to
bb8253a
Compare
.github/labeler.yml
Outdated
@@ -4,48 +4,68 @@ | |||
# The basic syntax is [label]: [path patterns]. | |||
# | |||
# For more details on the configuration please see: | |||
- changed-files: | |||
- any-glob-to-any-file: |
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 appears to be in the wrong commit: 3d9936f
The commit message doesn't seem to mention anything about the labeler.
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.
Yup, that was completely unrelated and sneaked in, good catch!
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.
so you've just removed the label stuff from here right?
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.
Yup
This is to be able to call `start()` without any arguments, so we can make the `MockMicrogrid` an async context manager, to make sure it is properly finalized after it is used. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
It will start when the context is entered and stop when it is left. This makes the `MockMicrogrid` easier to work with while ensure proper finalization. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
This commit updates many tests that use the `MockMicrogrid` and finalize it manually to use it as a context manager so finalization is done automatically. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use a custom async context manager for `_Mocks` so all used components get automatically finalized. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager so it gets automatically finalized. Before no finalization was done in the tests, except for only one. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager and an async exit stack so all used components get automatically finalized. Before no finalization was done in the tests. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager and an async exit stack so all used components get automatically finalized. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager, a custom async context manager and an async exit stack so all used components get automatically finalized. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager and an async exit stack so all used components get automatically finalized. Before some finalization was missing in the tests. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use the `MockMicrogrid` as a context manager and a custom async context manager for the `BatteryStatusTracker` so all used components get automatically finalized. Also uses `time_machine` as a `pytest` fixture when possible to simplify the tests and avoid having too indent too deep, as the previous approach used a context manager too, but not an async one, so it can be combined in the same `with` statement. This commit can be reviewed much more easily hiding differences in spaces (with `diff -w`, or appending `?w=1` to the GitHub URL). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Use an async exit stack to properly finalize the `Grid` object automatically. The finalization was missing in some tests. Also uses `time_machine` as a `pytest` fixture when possible to simplify the tests and avoid having too indent too deep, as the previous approach used a context manager too, but not an async one, so it can be combined in the same `with` statement. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
When the disable comment is in its own line, it will disable it for the rest of the function. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
bb8253a
to
17c17d5
Compare
Updated! |
typing
MockMicrogrid
an async context managerMockMicrogrid
as an async context manager