-
Notifications
You must be signed in to change notification settings - Fork 626
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
create and delete temporary directory using unittest methods #1132
create and delete temporary directory using unittest methods #1132
Conversation
python/tests/chunks.py
Outdated
def tearDown(self): | ||
mp.all_wait() | ||
if mp.am_master(): | ||
shutil.rmtree(self.temp_dir,ignore_errors=True) |
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.
Can just do mp.delete_directory(self.temp_dir)
now
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.
(need a rebase first)
2ec78de
to
4de4ba4
Compare
This is ready to be merged. Afterwards, it would be good to do a 1.13.1 tagged release. |
Merged and tagged. |
…p#1132) * create and delete temporary directory inside unittest methods * fixes * put meep.all_wait before rmtree to prevent race condition * put all_wait before delete_directory in h5test to prevent race condition * replace shutil.rmtree with meep.delete_directory * replace setUp/tearDown with setUpClass/tearDownClass * decorate setUpClass/tearDownClass with classmethod
#1121 involved creating and deleting a temporary directory directly within the
__main__
function. However, certain interpreters have script scope enforcement and do not allow thetemp_dir
directory name to be used outside of the__main__
function leading to an error. Also, on certain systems,os.removedirs
cannot delete non-empty directories and aborts with an error.This PR moves the creation of the temporary directory to within the
setUpClass
method of theunittest
mechanism and stores the directory name as a member of thecls
object. The directory deletion is moved to thetearDownClass
method andos.removedirs
is replaced withmeep.delete_output_directory
which can force the deletion of a non-empty directory and has a built-inall_wait()
to prevent race conditions.All the tests from #1121 have been updated with these changes.