-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Use pytest tmpdir_factory in gen_cluster #6630
Conversation
see #6625 (comment) |
tmpdir_factory is the old temporary path tool I think you should use https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-tmp-path-factory-fixture If you're injecting the fixture via the signature you can use the real tmp_path rather than the factory. |
daf2942
to
d8c654f
Compare
|
||
@functools.wraps(func) | ||
@clean(**clean_kwargs) | ||
def test_func(*outer_args, **kwargs): | ||
async def async_fn(): | ||
result = None | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
with contextlib.ExitStack() as exitstack: |
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 sure there is much more we could do with an exitstack int his function but I'd rather not touch it for now
tmp_path_factory = kwargs.get("tmp_path_factory") | ||
if tmp_path_factory is None: | ||
# For usage as plain ctxmanager for non-pytest functions | ||
tmpdir = str(exitstack.enter_context(_SafeTemporaryDirectory())) |
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.
There is unfortunately the case where tests are using this in an inner function w/out pytest-collection, i.e. we need to handle this case as well
Particularly with the latest changes to support non-pytest gen_cluster usage, I'm inclined to go with #6628 and see if this resolves our issue already. this turned out to be a bit ugly imo |
I'm also wondering if we have the opposite problem where tmp_path is being kept for the whole test suite and we're running out of disk space? |
I think we'd see different exceptions, wouldn't we? |
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 15 files 15 suites 10h 24m 54s ⏱️ For more details on these failures and errors, see this check. Results for commit d8c654f. |
closing in favor of #6628 |
Alternative to #6628
This will always infect the tmpdir_factory fixture to gen_cluster and use this for the creation of the tmpdir. If the function itself requires the fixture it will be forwarded to the function, otherwise we'll throw it away.