Skip to content
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

Question: Hook for subtest start #116

Closed
mrbean-bremen opened this issue Nov 27, 2023 · 3 comments
Closed

Question: Hook for subtest start #116

mrbean-bremen opened this issue Nov 27, 2023 · 3 comments

Comments

@mrbean-bremen
Copy link
Member

Hi,
I'm a maintainer for pyfakefs and currently trying to make it play nice with pytest-subtests (see this issue).
As pyfakefs patches the filesystem, I have to make sure that it is not active during reporting, so I currently suspend patching in pytest_runtest_logreport and resume it (provided the fixture is still active) in pytest_runtest_call.
This does not work with subtests, as pytest_runtest_logreport is called before each subtest (which suspends patching), but pytest_runtest_call is not, and I failed to find a hook to switch it back on before the next subtest. Is there a possibility (hook or otherwise) to get notified before a subtest is run which I can rely on?

Thanks!

@RonnyPfannschmidt
Copy link
Member

currently there is no such hook,

i just took note that the fix for pytest-dev/pyfakefs#904 is incorrect
i recommended a tryfirst hookwrapper as the hookwrapper can undo the suspense in the hook itself

the implementation https://github.com/pytest-dev/pyfakefs/pull/907/files does not use a hookwrapper

a non hookwrapper tryfirst hook will never be invoked before hookwrappers and would always require a extra hack for undoing

@mrbean-bremen
Copy link
Member Author

Thanks @RonnyPfannschmidt, I obviously got that wrong. Will fix this probably tomorrow.

@mrbean-bremen
Copy link
Member Author

mrbean-bremen commented Nov 28, 2023

I have to admit that I didn't know about hookwrappers - completely overlooked them in the documentation - so I probably just misunderstood that in your suggestion. A hookwrapper is quite useful and exactly what I was looking for, thanks!

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

No branches or pull requests

2 participants