call load_dot_env_file when initializing HttpRunner

This commit is contained in:
httprunner
2018-05-09 17:16:20 +08:00
parent 1b1dc8948e
commit a223ca04d3
6 changed files with 30 additions and 10 deletions

View File

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