Tests for PSA now use tempdir (fix for Issue #557)#575
Conversation
|
PSA tests fail (something about The failures due libgfortran missing are probably conda's fault again; I just raised #576. |
There was a problem hiding this comment.
TempDir() is a context manager and I think if you use it like TempDir().name (which would give you the directory name) then the directory will be created and immediately destroyed.
Either wrap the whole thing in
with tempdir.in_tempdir():or use tempfile.mkdtemp() explicitly together with explicit clean up in tearDown().
There was a problem hiding this comment.
Looking at the rest of the code, I think your only option is to do things explicitly with
import tempfile
import shutil
# ....
def setUp(self):
self.tempdir = tempfile.mkdtemp()
...
self.psa = MDAnalysis.analysis.psa.PSAnalysis(self.universes, ..., targetdir=self.tempdir)
def tearDown(self):
if self.tempdir:
shutil.rmtree(self.tempdir)
self.name = NoneThere was a problem hiding this comment.
You should not need to delete the outdir explicitly. tempdir will autodestruct as soon as the last reference is gone so your
del self.tempdirshould be enough.
|
Looking good; the test failures are #576 |
Tests for PSA now use tempdir Fixes Issue #557
Tests for PSA now construct a PSAnalysis object using
tempdir.TempDir()for thetargetdirkeyword. Thepsadatadirectory should now be created in a temporary directory and be properly cleaned up after the tests are completed.