Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

Y--
Copy link
Collaborator

@Y-- Y-- commented Apr 23, 2025

  • add helper to silence output
  • re-use MD user across all tests
  • add a wait_until helper

@Y-- Y-- changed the title Silence schema cleanup Small Python test improvements Apr 23, 2025
@Y-- Y-- force-pushed the yl/small-test-improvements branch from 289218c to 6badce7 Compare April 23, 2025 07:54
@Y-- Y-- requested a review from JelteF April 23, 2025 07:55
Comment on lines 280 to 281
yield
self.sql("RESET log_min_messages")
Copy link
Collaborator

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)

Suggested change
yield
self.sql("RESET log_min_messages")
try:
yield
finally:
self.sql("RESET log_min_messages")

Comment on lines 277 to 278
buffer = io.StringIO()
with redirect_stdout(buffer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

Comment on lines 320 to 321
self.wait_until(
lambda: self.try_sql(
Copy link
Collaborator

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)

Copy link
Collaborator

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.

),
dbname=dbname,
)
with self.silent_logs():
Copy link
Collaborator

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.

@JelteF JelteF force-pushed the yl/small-test-improvements branch from 47d79de to ca59815 Compare April 25, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants