-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add setUpClassPyfakefs convenience method #758
Conversation
- only available from Python 3.8 onwards - also add class-scoped 'fs_class' fixture - handle patcher for doc tests separately
548fdf3
to
728ee1c
Compare
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 just gave comments about improving the example code in the docstring.
|
||
|
||
class ExampleTestCase(TestCase): | ||
def setUpClass(cls): |
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.
Shouldn't there be an @classmethod
as 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.
Yes, looks like I botched the example... thanks, will correct this!
|
||
class ExampleTestCase(TestCase): | ||
def setUpClass(cls): | ||
self.setUpClassPyfakefs() |
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.
IMHO not self.
but cls.
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.
True of course.
class ExampleTestCase(TestCase): | ||
def setUpClass(cls): | ||
self.setUpClassPyfakefs() | ||
cls.file_path = "/test/file.txt" |
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.
Why so complicated? ;)
Just do
pathlib.Path('/test/file.txt').touch()
Isn't one of the great things of your package that I can do all file operations as usual because your package does the patching in background for me. No need to use fake_fs()
or create_file()
. Or do I misunderstand something?
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.
No, you understand correctly, this is just to demonstrate that you can access the fake fs from there, say to setup things that cannot be done in the real fs (like setting the file system size). But I may change this to make this more clear.
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 should have waited for a review before merging this - I tend to overlook simple stuff like that myself, especially in the evenings after my day job... next time.
The GitHub review mechanic do not show the correct lines here in my comments. But I hope you can understand them also. |
Tasks