[Piglit] [PATCH v4 1/6] framework/tests/utils.py: fix set_env decorator

Dylan Baker baker.dylan.c at gmail.com
Wed Jul 1 16:04:53 PDT 2015


This decorator sets environment variables, then runs the test, then
restores them.

If the value is stored as __DONOTRESTORE__, the idea is that it should
be deleted, otherwise it should be restored. But, before this patch it
would set the value to __DONOTRESTORE__ if the value was
__DONOTRESTORE__, and the key wasn't in os.environ.

This fixes that.

v4: - add this patch

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/tests/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/framework/tests/utils.py b/framework/tests/utils.py
index 0021681..438ffde 100644
--- a/framework/tests/utils.py
+++ b/framework/tests/utils.py
@@ -391,7 +391,7 @@ def set_env(**envargs):
                 for key, value in backup.iteritems():
                     if value == "__DONOTRESTORE__" and key in os.environ:
                         del os.environ[key]
-                    else:
+                    elif value != '__DONOTRESTORE__':
                         os.environ[key] = value
 
         return _inner
-- 
2.4.5



More information about the Piglit mailing list