-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: #1160 add support for pytest fixture as param
- Loading branch information
1 parent
401aaf6
commit ce9d761
Showing
7 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
examples/postman_echo/request_methods/request_with_fixtures.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
config: | ||
name: "request with fixture: session fixture" | ||
base_url: "https://postman-echo.com" | ||
fixture_as_param: ["session_fixture"] | ||
|
||
teststeps: | ||
- | ||
name: get with params | ||
request: | ||
method: GET | ||
url: /get | ||
params: | ||
info: "ip" | ||
headers: | ||
User-Agent: HttpRunner/${get_httprunner_version()}/${get_session_fixture($session_fixture)} |
41 changes: 41 additions & 0 deletions
41
examples/postman_echo/request_methods/request_with_fixtures_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# NOTE: Generated By HttpRunner v3.1.6 | ||
# FROM: request_methods/request_with_fixtures.yml | ||
|
||
|
||
import debugtalk | ||
import pytest | ||
|
||
|
||
import allure | ||
|
||
|
||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase | ||
|
||
|
||
class TestCaseRequestWithFixtures(HttpRunner): | ||
@allure.title("request teststep: with error retry") | ||
def test_start(self, session_fixture): | ||
scope, fixtures = locals(), ["session_fixture"] | ||
values = map(lambda x: scope.get(x), fixtures) | ||
super().test_start(fixtures=dict(zip(fixtures, values))) | ||
|
||
config = Config("request teststep: with error retry").base_url( | ||
"https://postman-echo.com" | ||
) | ||
|
||
teststeps = [ | ||
Step( | ||
RunRequest("get with params") | ||
.get("/get") | ||
.with_params(**{"info": "ip"}) | ||
.with_headers( | ||
**{ | ||
"User-Agent": "HttpRunner/${get_httprunner_version()}/${get_session_fixture($session_fixture)}" | ||
} | ||
) | ||
), | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
TestCaseRequestWithFixtures().test_start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters