bugfix: strip environment value

This commit is contained in:
debugtalk
2018-06-11 20:00:37 +08:00
parent 9dc53313e1
commit 6539640fc5
3 changed files with 4 additions and 2 deletions

View File

@@ -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'

View File

@@ -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):

View File

@@ -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):