Cross-Script Interface Association and Parameter Passing in HttpRunner3
The parameterization in HttpRunner3 utilizes the Pytest decorator @pytest.mark.parametrize().
1. Scenario Description
In the example from Baidu, the parameter passing for parameterization was not mentioned, so I will briefly describe the scenario here.
For instance, the interface in A.py depends on the return value of the interface in B.py, and then A uses this return value for the body parameters.
A uses the variable {'a':'1'} for parameterization, while B uses the variable {'a':1,'b':2,'c':3}.
At this point, when I run the A script, I get an error: b not found in {'a':'1'}.
So I was puzzled; my A script does not use this b variable, why does it not exist? It is B script that uses this variable.
Then I thought of the inheritance relationship with parameterized constructors. If A.__init__() inherits from B.__init__(), A must inherit the parameters of B.
At this point, my A parameterization changes to {'a':4,'b':5,'c':6}. This resolved the issue.
Summary: 1. A depends on B, and A's parameterization must include B's variables (parameters). Parameters are passed from A.
2. At this time, A's parameters will override B's, changing B's parameters to {'a':4,'b':5,'c':6}.
3. When B runs independently, the parameters are still {'a':1,'b':2,'c':3}.
2. Code Analysis
B.py Code


A.py Code

Here, T is the alias I imported for the class name from B.py. For example: from B import class_name as T
