Skip to content

Question: How can I parameterize my tests with global variable which changes values on runtime. #3273

Closed
@thakkardharmik

Description

@thakkardharmik

Question: How can I parameterize my tests with global variable which changes values on runtime.
I have a global list variable which I populate the value in one of the test and I am using this variable to parameterize another test. One way I found out was to use pickle. Is there any other way I can handle this scenario?

Example -

myList = []

def test_1():
    global myList
    myList = [1,2,3]

#This test should print 1,2,3
@pytest.mark.parameterize("num", myList)
def test_2(num):
    print(num)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions