From: Vincent Danno Date: Mon, 10 May 2021 07:28:36 +0000 (+0200) Subject: Remove unnecessary condition in statement flow X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F72492%2F1;p=functest-xtesting.git Remove unnecessary condition in statement flow First, the condition should be limited to only defining the default value, rather than applying to the statement flow. This not only avoids unnecessary repetition of statements, but is more logical. Second, it is not even necessary to explicitly code a condition here, because the language itself defaults to our desired default value. Signed-off-by: Vincent Danno Change-Id: I119567f5b31444a0e864ba41dee8a5f640ff0c22 --- diff --git a/xtesting/utils/env.py b/xtesting/utils/env.py index 042ab675..83484914 100644 --- a/xtesting/utils/env.py +++ b/xtesting/utils/env.py @@ -30,9 +30,8 @@ INPUTS = { def get(env_var): - if env_var not in INPUTS.keys(): - return os.environ.get(env_var, None) - return os.environ.get(env_var, INPUTS[env_var]) + # defaults to None if env_var is not found + return os.environ.get(env_var, INPUTS.get(env_var)) def string():