Browse Source

[1545] Corrected problems in setting environment variable in tests

For some reason, the Python "os.putenv()" did not work, so changed
to morifying the "os.environ" variable directly.
Stephen Morris 12 years ago
parent
commit
d6f3e1aa02
2 changed files with 8 additions and 8 deletions
  1. 4 4
      src/bin/dhcp4/tests/dhcp4_test.py
  2. 4 4
      src/bin/dhcp6/tests/dhcp6_test.py

+ 4 - 4
src/bin/dhcp4/tests/dhcp4_test.py

@@ -32,11 +32,11 @@ class TestDhcpv4Daemon(unittest.TestCase):
         #
         # However, we do want to set the logging lock directory to somewhere
         # to which we can write - use the current working directory.  We then
-        # set the appropriate environment variable.
+        # set the appropriate environment variable.  os.putenv() doesn't work
+        # on Ubuntu, so we access os.environ directly.
         lockdir_envvar = "B10_LOCKFILE_DIR_FROM_BUILD"
-        lockdir = os.getenv(lockdir_envvar)
-        if lockdir is None:
-            os.putenv(lockdir_envvar, os.getcwd())
+        if lockdir_envvar not in os.environ:
+            os.environ[lockdir_envvar] = os.getcwd()
 
     def tearDown(self):
         pass

+ 4 - 4
src/bin/dhcp6/tests/dhcp6_test.py

@@ -32,11 +32,11 @@ class TestDhcpv6Daemon(unittest.TestCase):
         #
         # However, we do want to set the logging lock directory to somewhere
         # to which we can write - use the current working directory.  We then
-        # set the appropriate environment variable.
+        # set the appropriate environment variable.  os.putenv() doesn't work
+        # on Ubuntu, so we access os.environ directly.
         lockdir_envvar = "B10_LOCKFILE_DIR_FROM_BUILD"
-        lockdir = os.getenv(lockdir_envvar)
-        if lockdir is None:
-            os.putenv(lockdir_envvar, os.getcwd())
+        if lockdir_envvar not in os.environ:
+            os.environ[lockdir_envvar] = os.getcwd()
 
     def tearDown(self):
         pass