Browse files

Make buildout base configurable via environment variable.

  • Loading branch information...
1 parent 54ed9ea commit 641e5f8ff8c78ca2882baa84798c815241e619d7 @fschulze committed Mar 22, 2012
Showing with 31 additions and 0 deletions.
  1. +2 −0 src/mr/developer/develop.py
  2. +29 −0 src/mr/developer/tests/test_develop.py
View
2 src/mr/developer/develop.py
@@ -16,6 +16,8 @@
def find_base():
+ if 'MRDEVELOPER_BASE' in os.environ:
+ return os.environ['MRDEVELOPER_BASE']
path = os.getcwd()
while path:
if os.path.exists(os.path.join(path, '.mr.developer.cfg')):
View
29 src/mr/developer/tests/test_develop.py
@@ -1,4 +1,7 @@
from unittest import TestCase
+import os
+import tempfile
+import shutil
class MockDevelop(object):
@@ -72,3 +75,29 @@ def testArgsMatchingMultiple2Auto(self):
pkgs = Command(self.develop).get_packages(['ha', 'ba'],
auto_checkout=True)
self.assertEquals(pkgs, set(['ham']))
+
+
+class TestFindBase(TestCase):
+ def setUp(self):
+ self.location = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.location)
+
+ def testEnvironmentVar(self):
+ from mr.developer.develop import find_base
+ subdir = os.path.join(self.location, 'subdir')
+ os.mkdir(subdir)
+ devdir = os.path.join(self.location, 'devdir')
+ os.mkdir(devdir)
+ open(os.path.join(devdir, '.mr.developer.cfg'), 'w').close()
+ orig_dir = os.getcwd()
+ try:
+ os.chdir(subdir)
+ self.assertRaises(IOError, find_base)
+ os.environ['MRDEVELOPER_BASE'] = devdir
+ self.assertEqual(find_base(), devdir)
+ finally:
+ os.chdir(orig_dir)
+ if 'MRDEVELOPER_BASE' in os.environ:
+ del os.environ['MRDEVELOPER_BASE']

0 comments on commit 641e5f8

Please sign in to comment.