From 6539640fc5f4be496efb210aab9e377a25ba82b8 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 11 Jun 2018 20:00:37 +0800 Subject: [PATCH] bugfix: strip environment value --- httprunner/__about__.py | 2 +- httprunner/utils.py | 3 ++- tests/test_httprunner.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/httprunner/__about__.py b/httprunner/__about__.py index d2304f8d..cfcc2fe6 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '1.4.5' +__version__ = '1.4.6' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/httprunner/utils.py b/httprunner/utils.py index ea079540..3a508d86 100644 --- a/httprunner/utils.py +++ b/httprunner/utils.py @@ -513,7 +513,8 @@ def load_dot_env_file(path): with io.open(path, 'r', encoding='utf-8') as fp: for line in fp: variable, value = line.split("=") - os.environ[variable] = value + variable = variable.strip() + os.environ[variable] = value.strip() logger.log_debug("Loaded variable: {}".format(variable)) def validate_json_file(file_list): diff --git a/tests/test_httprunner.py b/tests/test_httprunner.py index c3b9d6a7..4d940e3f 100644 --- a/tests/test_httprunner.py +++ b/tests/test_httprunner.py @@ -158,6 +158,7 @@ class TestHttpRunner(ApiServerUnittest): self.assertNotIn("PROJECT_KEY", os.environ) HttpRunner(dot_env_path="tests/data/test.env").run(self.testset_path) self.assertIn("PROJECT_KEY", os.environ) + self.assertEqual(os.environ["UserName"], "debugtalk") def test_load_env_path_not_exist(self): with self.assertRaises(FileNotFoundError):