mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-20 07:40:32 +08:00
call load_dot_env_file when initializing HttpRunner
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import shutil
|
||||
|
||||
from httprunner import HttpRunner
|
||||
from httprunner.exception import FileNotFoundError
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
|
||||
@@ -152,3 +153,12 @@ class TestHttpRunner(ApiServerUnittest):
|
||||
summary = runner.summary
|
||||
self.assertTrue(summary["success"])
|
||||
self.assertEqual(summary["stat"]["testsRun"], 8)
|
||||
|
||||
def test_load_env_path(self):
|
||||
self.assertNotIn("PROJECT_KEY", os.environ)
|
||||
HttpRunner(dot_env_path="tests/data/test.env").run(self.testset_path)
|
||||
self.assertIn("PROJECT_KEY", os.environ)
|
||||
|
||||
def test_load_env_path_not_exist(self):
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
HttpRunner(dot_env_path="not_exist.env").run(self.testset_path)
|
||||
|
||||
Reference in New Issue
Block a user