mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-11 10:49:43 +08:00
fix #392: multiple '=' in .env file
This commit is contained in:
@@ -192,9 +192,9 @@ def load_dot_env_file():
|
|||||||
with io.open(path, 'r', encoding='utf-8') as fp:
|
with io.open(path, 'r', encoding='utf-8') as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
if "=" in line:
|
if "=" in line:
|
||||||
variable, value = line.split("=")
|
variable, value = line.split("=", maxsplit=1)
|
||||||
elif ":" in line:
|
elif ":" in line:
|
||||||
variable, value = line.split(":")
|
variable, value = line.split(":", maxsplit=1)
|
||||||
else:
|
else:
|
||||||
raise exceptions.FileFormatError(".env format error")
|
raise exceptions.FileFormatError(".env format error")
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
UserName=test
|
UserName=test
|
||||||
Password=654321
|
Password=654321
|
||||||
PROJECT_KEY=AAABBBCCC
|
PROJECT_KEY=AAABBBCCC
|
||||||
|
content_type=application/json; charset=UTF-8
|
||||||
@@ -148,6 +148,7 @@ class TestFileLoader(unittest.TestCase):
|
|||||||
env_variables_mapping = loader.load_dot_env_file()
|
env_variables_mapping = loader.load_dot_env_file()
|
||||||
self.assertIn("PROJECT_KEY", env_variables_mapping)
|
self.assertIn("PROJECT_KEY", env_variables_mapping)
|
||||||
self.assertEqual(env_variables_mapping["UserName"], "test")
|
self.assertEqual(env_variables_mapping["UserName"], "test")
|
||||||
|
self.assertEqual(env_variables_mapping["content_type"], "application/json; charset=UTF-8")
|
||||||
loader.dot_env_path = None
|
loader.dot_env_path = None
|
||||||
|
|
||||||
def test_load_env_path_not_exist(self):
|
def test_load_env_path_not_exist(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user