summaryrefslogtreecommitdiff
path: root/linaropy/proj.py
diff options
context:
space:
mode:
Diffstat (limited to 'linaropy/proj.py')
-rw-r--r--linaropy/proj.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/linaropy/proj.py b/linaropy/proj.py
index b20d96b..aeff057 100644
--- a/linaropy/proj.py
+++ b/linaropy/proj.py
@@ -40,19 +40,24 @@ class Proj(object):
"""
if existing_projdir:
- if not isinstance (existing_projdir,basestring):
+ if not isinstance(existing_projdir, str):
raise TypeError("The 'existing_projdir' must be a string.")
if prefix:
- logging.warning("'existing_proj' specified so 'prefix'=%s ignored" % prefix)
+ logging.warning(
+ "'existing_proj' specified so 'prefix'=%s ignored" %
+ prefix)
if not persist:
- logging.warning("'existing_proj' specified, 'persist' forced to True.")
+ logging.warning(
+ "'existing_proj' specified, 'persist' forced to True.")
if not os.path.isdir(existing_projdir):
- raise IOError('existing_projdir %s not found.' % existing_projdir)
+ raise IOError(
+ 'existing_projdir %s not found.' %
+ existing_projdir)
else:
- self.persist= True
- self.longevity= "persistent"
+ self.persist = True
+ self.longevity = "persistent"
self.projdir = os.path.abspath(existing_projdir)
else:
# This allows string or bool inputs.
@@ -63,10 +68,10 @@ class Proj(object):
self.persist = False
self.longevity = "temporary"
- self.projdir = unicode(tempfile.mkdtemp(prefix=prefix), "utf-8")
+ self.projdir = str(tempfile.mkdtemp(prefix=prefix))
logging.info("Using %s as %s project directory." %
- (self.projdir, self.longevity))
+ (self.projdir, self.longevity))
def cleanup(self):
"""Perform cleanup (removal) of the proj directory if Proj persist==False."""
@@ -79,6 +84,7 @@ class Proj(object):
else:
logging.info("Project dir %s will persist" % self.projdir)
+
class TestProj(unittest.TestCase):
"""Test the Proj class."""
@@ -152,6 +158,7 @@ class TestProj(unittest.TestCase):
if self.persistdir != "/" and self.persistdir != "/home":
rm("-rf", "--preserve-root", self.persistdir)
+
class TestExisting_Projdir(unittest.TestCase):
"""Test the Proj class when existing_projdir is set."""
@@ -177,7 +184,9 @@ class TestExisting_Projdir(unittest.TestCase):
# Verify that prefix is properly ignored when reusing a proj dir.
def test_existing_projdir(self):
- self.proj = Proj(prefix="shouldntmatch", existing_projdir=self.reuse_proj.projdir)
+ self.proj = Proj(
+ prefix="shouldntmatch",
+ existing_projdir=self.reuse_proj.projdir)
self.assertFalse(self.proj.projdir.startswith("shouldntmatch"))
self.proj.cleanup()