-
Notifications
You must be signed in to change notification settings - Fork 293
TST: migrate module-level setup/teardown functions to pytest #4852
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
TST: migrate module-level setup/teardown functions to pytest #4852
Conversation
d426a38
to
3216abf
Compare
Interesting... this fails even on pytest but errors resist introspection (this smells like another case of test pollution). Let me see what I can do. |
Does |
debe885
to
f2f4cb6
Compare
Oh, good point, I didn't think of that 🤦🏻♂️ |
f2f4cb6
to
f87c2f5
Compare
d2da8bc
to
a6e392e
Compare
--ignore-file=test_gadget_pytest\.py | ||
--ignore-file=test_vr_orientation\.py | ||
--ignore-file=test_particle_trajectories_pytest\.py | ||
--ignore-file=test_image_array\.py |
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.
note to reviewers:
I've added modules that are now pytest-only due to usage of teardown_module
. Many other modules have a setup_module
method bu no teardown_method
, and what they effectively do in setups seems safe (as in, free of side effects), and, to the best of my knowledge, is not actually used in nose.
def setup_module():
from yt.config import ytcfg
ytcfg["yt", "internals", "within_testing"] = True
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.
Thanks, that makes sense. Do you think that having pytest-only modules will change the relative runtimes of the different test suites?
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.
not in any significant way. The four modules I just made pytest-only (combined) only take a couple seconds to run locally.
@yt-fido test this please |
def setup(): | ||
|
||
def setup_module(): | ||
global old_serialize |
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.
it'd be nice to have a pytest fixture for patching yt config options...
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'm not sure that fixtures are flexible enough to do that, but we might be able to achieve this with a context manager wrapped in a decorator ?
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 was thinking that a fixture that used the monkeypatch fixture internally might work -- I was just playing around with making a copy of a YTConfig instance, modifying a value and then using monkeypatch to set yt.config.ytcfg
to point to the modified copy and it seemed to work. But it was a little circuitous and a more general context manager would much clearer.
In any case, a discussion for a different issue/PR :)
… functions to pytest
…2-on-yt-4.3.x Backport PR #4852 on branch yt-4.3.x (TST: migrate module-level setup/teardown functions to pytest)
PR Summary
This fixes part of #4850, and effectively migrates part of the test suite away from nosetest.
It's also based off of #4849
xref pytest-dev/pytest#12113
Opening with a simple find/replace. I'll see which affected modules are still run on nose and wether they can simply be ignored there. If more work is needed to migrate them I'll simply make them nose-only as a quick fix.