Skip to content

feat(tests): use logger instead of printing #920

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

inducer
Copy link
Owner

@inducer inducer commented Feb 19, 2025

@@ -580,8 +580,7 @@ def test_poisson_fem(ctx_factory):
J[c] * w[k] * sum(ell, dpsi(i,k,ell) * dpsi(j,k,ell))
""",
assumptions="nels>=1 and nbf >= 1 and nels mod 4 = 0")

print(knl)
logger.info("%s", knl)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is kind of a weird pattern to me. Does logger.info(knl) not work?

Copy link
Contributor

@alexfikl alexfikl Feb 19, 2025

Choose a reason for hiding this comment

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

I never actually tried that, but yeah, seems to work! :)) That would have been much easier to search and replace..

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure I'm in love with these changes. print seems just fine to me; pytest suppresses stdout anyway. Could you explain the motivation a bit?

Copy link
Contributor

@alexfikl alexfikl Feb 19, 2025

Choose a reason for hiding this comment

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

I can't say I feel very strongly about this, so feel free to drop it. 😕

I mostly tried to use logging things because (1) they can write to stderr (by default, right?) or files and (2) add time stamps and things like that. But yeah, not sure those are super useful in tests..

@inducer inducer mentioned this pull request Feb 19, 2025
@inducer
Copy link
Owner Author

inducer commented Feb 19, 2025

Thanks for responding! I think I might just leave this here for now. Maybe it'll turn out later that we want it. 🙂

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