summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames Falcon <TheRealFalcon@users.noreply.github.com>2020-12-15 10:31:27 -0600
committerGitHub <noreply@github.com>2020-12-15 11:31:27 -0500
commit2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a (patch)
treef7323fdc73f2729ecfd6350b86346bec7aa6fc7d /tests
parent3339a5a4680e79fecb09907089239e6749e08a54 (diff)
downloadvyos-cloud-init-2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a.tar.gz
vyos-cloud-init-2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a.zip
Ensure overriding test vars with env vars works for booleans (#727)
Diffstat (limited to 'tests')
-rw-r--r--tests/integration_tests/integration_settings.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/integration_tests/integration_settings.py b/tests/integration_tests/integration_settings.py
index 9948d479..d7e02f04 100644
--- a/tests/integration_tests/integration_settings.py
+++ b/tests/integration_tests/integration_settings.py
@@ -1,6 +1,8 @@
# This file is part of cloud-init. See LICENSE file for license information.
import os
+from distutils.util import strtobool
+
##################################################################
# LAUNCH SETTINGS
##################################################################
@@ -109,6 +111,12 @@ except ImportError:
# Perhaps a bit too hacky, but it works :)
current_settings = [var for var in locals() if var.isupper()]
for setting in current_settings:
- globals()[setting] = os.getenv(
+ env_setting = os.getenv(
'CLOUD_INIT_{}'.format(setting), globals()[setting]
)
+ if isinstance(env_setting, str):
+ try:
+ env_setting = bool(strtobool(env_setting.strip()))
+ except ValueError:
+ pass
+ globals()[setting] = env_setting