-
Notifications
You must be signed in to change notification settings - Fork 50
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
fix[tests]: clear log capture at start of local mode solver test #2171
Conversation
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.
Actually, maybe we should wrap this in
with AssertLogLevel(log_capture, ...)
rather than the current context-free approach.
this might be the appropriate solution throughout?
I think the old assert_log_level
syntax should be removed globally in favor of with AssertLogLevel(log_capture, "WARNING", contains_str="..."):
would this fix the threaded test issue?
That's probably a good idea in general but does not fix the underlying issue here, since the context manager does not clear the captured logs. So essentially, with AssertLogLevel(log_capture, "WARNING", contains_str="ModeSpec") as ctx:
assert modes.n_group is None
assert len(ctx.records) == 1 and assert modes.n_group is None
assert len(log_capture) == 1 are equivalent in that sense. I changed it so we are not checking the length of the records at all and are instead only checking the actual message generated within the context manager, which should be ok for these tests? I'll make an issue for doing this change globally but for now this will fix the failing CI. |
e974db3
to
3573f46
Compare
Hmmm, I would think it would fix the underlying issue since the context manager |
The way that I think more fundamentally the issue is that many of our tests are written in a way that doesn't isolate individual warning cases, and some even work around the fact that there is some global logging state. I was intending this PR to be a quick fix to get CI passing so that it's not blocking other PRs anymore, but I guess I can come up with a more complete fix too. |
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.
Got it now regarding the context manager. Yeah up to you, this sounds good as a quick fix!
4bdfd95
to
b5f7e77
Compare
Ok, bit the bullet. Main changes are:
For the most part, the |
@yaugenst-flex this is awesome! should be much cleaner and safer this way. One comment is that it really does seem like we can just get rid of |
b5f7e77
to
7e2acac
Compare
Yeah good point, I was considering this but was a bit hesitant to change the behavior of the tests. Updated, |
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.
Nice idea on the raise with AssertLogLevel
! Looks good, thanks Yannick.
7e2acac
to
7672e35
Compare
This is a band-aid fix for the test coupling. Works for this specific case, but we'll need to do more robust warning capturing if we want to avoid dealing with this in the future.