s4-python-test: Common implementation for getting environment variable value
authorKamen Mazdrashki <kamenim@samba.org>
Wed, 29 Sep 2010 11:53:12 +0000 (14:53 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Sat, 2 Oct 2010 22:24:56 +0000 (01:24 +0300)
Unit-test based python tests require certain input parameters
to be set in environment, otherwise they can't be run

source4/scripting/python/samba/tests/__init__.py

index bf7c563c4eb728a889b0acd680da6d13bce29ce2..7a5c2aa694af165d60649bd488e348b8378c86bf 100644 (file)
@@ -68,6 +68,17 @@ def env_loadparm():
         raise Exception("SMB_CONF_PATH not set")
     return lp
 
+def env_get_var_value(var_name):
+    """Returns value for variable in os.environ
+
+    Function throws AssertionError if variable is defined.
+    Unit-test based python tests require certain input params
+    to be set in environment, otherwise they can't be run
+    """
+    assert var_name in os.environ.keys(), "Please supply %s in environment" % var_name
+    return os.environ[var_name]
+
+
 cmdline_credentials = None
 
 class RpcInterfaceTestCase(TestCase):