diff --git a/httprunner/loader.py b/httprunner/loader.py index 75d8e535..07761bcf 100644 --- a/httprunner/loader.py +++ b/httprunner/loader.py @@ -192,9 +192,9 @@ def load_dot_env_file(): with io.open(path, 'r', encoding='utf-8') as fp: for line in fp: if "=" in line: - variable, value = line.split("=") + variable, value = line.split("=", maxsplit=1) elif ":" in line: - variable, value = line.split(":") + variable, value = line.split(":", maxsplit=1) else: raise exceptions.FileFormatError(".env format error") diff --git a/tests/data/test.env b/tests/data/test.env index 09816d83..74d5d9ec 100644 --- a/tests/data/test.env +++ b/tests/data/test.env @@ -1,3 +1,4 @@ UserName=test Password=654321 -PROJECT_KEY=AAABBBCCC \ No newline at end of file +PROJECT_KEY=AAABBBCCC +content_type=application/json; charset=UTF-8 \ No newline at end of file diff --git a/tests/test_loader.py b/tests/test_loader.py index 18e67d86..03f8e4e0 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -148,6 +148,7 @@ class TestFileLoader(unittest.TestCase): env_variables_mapping = loader.load_dot_env_file() self.assertIn("PROJECT_KEY", env_variables_mapping) self.assertEqual(env_variables_mapping["UserName"], "test") + self.assertEqual(env_variables_mapping["content_type"], "application/json; charset=UTF-8") loader.dot_env_path = None def test_load_env_path_not_exist(self):