Skip to content

Tests for PSA now use tempdir (fix for Issue #557)#575

Merged
orbeckst merged 5 commits into
MDAnalysis:developfrom
sseyler:develop
Dec 10, 2015
Merged

Tests for PSA now use tempdir (fix for Issue #557)#575
orbeckst merged 5 commits into
MDAnalysis:developfrom
sseyler:develop

Conversation

@sseyler

@sseyler sseyler commented Dec 9, 2015

Copy link
Copy Markdown
Contributor

Tests for PSA now construct a PSAnalysis object using tempdir.TempDir() for the targetdir keyword. The psadata directory should now be created in a temporary directory and be properly cleaned up after the tests are completed.

@orbeckst

Copy link
Copy Markdown
Member

PSA tests fail (something about Tempdir not having .startswith method) – please fix.

The failures due libgfortran missing are probably conda's fault again; I just raised #576.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to delete the outdir explicitly. tempdir will autodestruct as soon as the last reference is gone so your

del self.tempdir

should be enough.

@orbeckst orbeckst self-assigned this Dec 10, 2015
@orbeckst

Copy link
Copy Markdown
Member

Looking good; the test failures are #576

orbeckst added a commit that referenced this pull request Dec 10, 2015
Tests for PSA now use tempdir

Fixes Issue #557
@orbeckst orbeckst merged commit a125286 into MDAnalysis:develop Dec 10, 2015
@mnmelo mnmelo mentioned this pull request Dec 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants