Skip to content

How can I use global variables through tests? #3118

Closed
@UANEMESIS

Description

@UANEMESIS

In my example:

@pytest.fixture
def global_var():
    pytest.global_variable_1 = 100

def test_1(global_var):
	pytest.global_variable_1 +=1
	print(pytest.global_variable_1)

def test_2(global_var):
	pytest.global_variable_1 +=1
	print(pytest.global_variable_1)

def test_3(global_var):
	pytest.global_variable_1 +=1
	print(pytest.global_variable_1)

Global variable pytest.global_variable works only in test_1. output:
101
101
101

What do I wrong in?

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