-
Notifications
You must be signed in to change notification settings - Fork 99
Small Python test improvements #727
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
base: main
Are you sure you want to change the base?
Conversation
289218c
to
6badce7
Compare
test/pycheck/utils.py
Outdated
yield | ||
self.sql("RESET log_min_messages") |
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 think it would be good to clean up using a finally
.
(don't apply suggestion verbatim it mixes tabs and spaces it seems)
yield | |
self.sql("RESET log_min_messages") | |
try: | |
yield | |
finally: | |
self.sql("RESET log_min_messages") |
test/pycheck/utils.py
Outdated
buffer = io.StringIO() | ||
with redirect_stdout(buffer): |
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.
Is this still needed?
test/pycheck/utils.py
Outdated
self.wait_until( | ||
lambda: self.try_sql( |
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.
nit: Instead of waiting for a predicate, how about we wait until no exception occurs. Then we can make this a context manager, instead of having to use lambdas. (in case you haven't noticed. I much prefer context managers over lambdas in python)
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.
Feel free to merge without changing this. I can create a follow up PR to make this a bit nicer.
test/pycheck/utils.py
Outdated
), | ||
dbname=dbname, | ||
) | ||
with self.silent_logs(): |
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.
What errors/warnings is this silencing? Would be good to add a comment, because I wouldn't expect the below code to throw an error/warning.
47d79de
to
ca59815
Compare
wait_until
helper