Browse Source

HUE-8630 [core] Fix test_dump_config & test_config_check HUE_CONF_DIR

jdesjean 7 năm trước cách đây
mục cha
commit
ffb6a19
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      desktop/core/src/desktop/tests.py

+ 4 - 2
desktop/core/src/desktop/tests.py

@@ -237,12 +237,13 @@ def test_dump_config():
   response = client_not_me.get(reverse('desktop.views.dump_config'))
   assert_true("You must be a superuser" in response.content, response.content)
 
+  prev_env_conf = os.environ["HUE_CONF_DIR"]
   try:
     os.environ["HUE_CONF_DIR"] = "/tmp/test_hue_conf_dir"
     resp = c.get(reverse('desktop.views.dump_config'))
     assert_true('/tmp/test_hue_conf_dir' in resp.content, resp)
   finally:
-    del os.environ["HUE_CONF_DIR"]
+    os.environ["HUE_CONF_DIR"] = prev_env_conf
 
 def hue_version():
   global HUE_VERSION
@@ -755,6 +756,7 @@ def test_config_check():
         for old_conf in reset:
           old_conf()
 
+      prev_env_conf = os.environ["HUE_CONF_DIR"]
       try:
         # Set HUE_CONF_DIR and make sure check_config returns appropriate conf
         os.environ["HUE_CONF_DIR"] = "/tmp/test_hue_conf_dir"
@@ -769,7 +771,7 @@ def test_config_check():
         resp = cli.get('/desktop/debug/check_config')
         assert_true('/tmp/test_hue_conf_dir' in resp.content, resp)
       finally:
-        del os.environ["HUE_CONF_DIR"]
+        os.environ["HUE_CONF_DIR"] = prev_env_conf
         desktop.views.validate_by_spec = desktop.views.real_validate_by_spec
 
 def test_last_access_time():