svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

Feature request: Global variables for import #256

Open j796160836 opened 7 years ago

j796160836 commented 7 years ago

Hi,
I also using this awesome framework.
It does have import yaml test case, but variables are independent between child and parent.

- import: a.yaml

https://github.com/svanoort/pyresttest#import-example

I'm looking for global variables define and expose to child.
Here is my idea,

main.yaml

# Test case entrance
---
- config:
    - testset: "Test case"

- import: a.yaml
- import: b.yaml
- import: c.yaml

a.yaml

# Test set A
---
- config:
    - testset: "Test set A"
    - global_variables: variables.yaml  # Get the global variables from file
- test:
     do stuff

b.yaml

# Test set B
---
- config:
    - testset: "Test set B"
    - global_variables: variables.yaml  # Get the global variables from file
- test:
     # do some stuff

variables.yaml

# Global variables
---
- config:
    - variable_binds: {"foo": "bar"}

Is that possible to do this? If someone can gave me a guide will be great, thanks.