-
Notifications
You must be signed in to change notification settings - Fork 94
Added pytest plugin support #156
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
Conversation
|
"Any support for adding this to pyfakefs?" You're so funny, @wesleykendall. Hell yeah there's support for that! A paragraph or two in README.md would be appropriate for documentation. This needs a test, which would require pytest, but on the other hand, we need to ensure that pyfakefs works without pytest. Ideas? |
|
@jmcgeheeiv awesome! Here's what I attempted to do in the most recent commits:
Anything else that might be worth adding? I can update the wiki too. Something worth noting - pytest has deprecated |
|
You could check for the pytest version to decide which decorator to use. Something along the lines of: from distutils.version import LooseVersion
is_pytest2 = LooseVersion(pytest.__version__) < LooseVersion('3')
pytest_fixture = pytest.yield_fixture if is_pytest2 else pytest.fixture
@pytest_fixture
def fs()
...Edit: ok, you already fixed this in a nicer way while I was writing :) |
|
@mrbean-bremen @jmcgeheeiv I just got around this issue with using |
|
@mrbean-bremen, you have been watching this PR more carefully than me, so please take care of the merge as you see fit. @wesleykendall, thanks a bunch for the contribution! |
|
@megapctr, I think you will be interested in this new capability. |
|
@wesleykendall, thanks a lot! |
|
@mrbean-bremen @jmcgeheeiv Thanks! Any idea when this will be released? |
|
I certainly would plead for a new release here, as this change makes using pytest with pyfakefs much more convenient - though @jmcgeheeiv has to do the release work, and we just had a release... |
|
I'll see what I can do this weekend. |
|
@wesleykendall, @mrbean-bremen, @megapctr |
|
Thanks - that was fast! |
|
Thanks! |
Hello, I love this library and would really like to use it as a pytest fixture in my tests without having to define it myself. This PR adds a pytest plugin as part of the installation for pyfakefs. In other words, installing pyfakefs allows one to do:
I used your example in conftest.py, along with returning the
fsattribute of the createdPatcherobject. Everything works so far in my fakefs tests.Any support for adding this to pyfakefs? I'll gladly write some more docs if desired. Thanks for the feedback