-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix chdir and add tests for fsutils functions #45
Conversation
src/wxflow/fsutils.py
Outdated
if missing_ok: | ||
logger.warning(f"WARNING cannot remove the target path {dir_path} because it does not exist") | ||
else: | ||
raise exc |
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.
raise exc | |
raise FileNotFoundError() |
Should this raise this error specifically. Not sure how this works, if its trying to remove something that is not existant.
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.
Since exc
is the original FileNotFoundError
, raising exc
is equivalent to raising FileNotFoundError
. But, raising a custom FileNotFoundError
with an more specific error message would be useful. I'll add that in.
So if the file doesn't exist, nothing will happen but rmtree
will return a FileNotFoundError
. If missing_ok=False
, then this Exception will be passed on. Otherwise, you get a warning for trying.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #45 +/- ##
===========================================
+ Coverage 50.12% 52.41% +2.29%
===========================================
Files 18 18
Lines 1652 1679 +27
Branches 339 296 -43
===========================================
+ Hits 828 880 +52
+ Misses 765 749 -16
+ Partials 59 50 -9 ☔ View full report in Codecov by Sentry. |
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.
lgtm. thanks for beefing up fsutils and adding tests.
Description
This modifies
chdir
so that it produces an error if the target directory is not available and returns to the original working directory when thewith
completes without producing a warning.Tests were added to verify that
chdir
, as well as the otherfsutils
, run as expected. While writing these tests, the following issues were found and fixed:mkdir_p
was simplified to use theos.mkdir
exist_ok=True
parameter instead of attempting to handle that in wxflow.missing_ok
parameter tormdir
to allow missing directories to be skipped without error.rm_p
error handling and added amissing_ok
parameter.Lastly, the only function that did not have a test added was
chgrp
. I am not sure what groups are available on GitHub runners, so I am not sure how this could be tested reliably.Type of change
How Has This Been Tested?
Checklist