Lars Yencken avatar Lars Yencken committed 386d8b6

Pass through drake special variables.

Comments (0)

Files changed (2)


 from shutil import copy, move, copytree, rmtree  # noqa
-from os import path, rename, stat  # noqa
+from os import environ, path, rename, stat  # noqa
 from datetime_tz import datetime_tz
 import subprocess
+# set up special drake environment variables
+for k in environ:
+    if k.startswith('INPUT') or k.startswith('OUTPUT'):
+        locals()[k] = environ[k]
 def hdfs_timestamp(filename):
     "When was this file last modified?"
     stdout, stderr = subprocess.Popen(['hadoop', 'fs', '-stat', filename],

 import unittest
 from datetime_tz import datetime_tz as datetime
 import os
-import drakeutil
+import sys
 class DrakeHelperTest(unittest.TestCase):
+    def setUp(self):
+        if 'drakeutil' in sys.modules:
+            del sys.modules['drakeutil']
+        self.du = __import__('drakeutil')
     def test_file_mtime(self):
         expected = datetime.utcfromtimestamp(
-        self.assertEquals(drakeutil.file_timestamp(__file__), expected)
+        self.assertEquals(self.du.file_timestamp(__file__), expected)
     def test_file_mtime_missing(self):
-        self.assertEquals(drakeutil.file_timestamp(__file__ + '.unlikely'),
+        self.assertEquals(self.du.file_timestamp(__file__ + '.unlikely'),
+class DrakeEnvTest(unittest.TestCase):
+    def setUp(self):
+        os.environ['INPUT'] = 'input'
+        os.environ['OUTPUT'] = 'output'
+        if 'drakeutil' in sys.modules:
+            del sys.modules['drakeutil']
+        self.du = __import__('drakeutil')
+    def test_special(self):
+        self.assertEquals(self.du.INPUT, 'input')
+        self.assertEquals(self.du.OUTPUT, 'output')
+def suite():
+    return unittest.TestSuite((
+            unittest.makeSuite(DrakeHelperTest),
+            unittest.makeSuite(DrakeEnvTest),
+        ))
 if __name__ == '__main__':
-    unittest.TextTestRunner(verbosity=1).run(
-            unittest.makeSuite(DrakeHelperTest)
-        )
+    unittest.TextTestRunner(verbosity=1).run(suite())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.