Skip to content

Update the environtment variable #17

@ianrussel

Description

@ianrussel

HI, I have a scenario to test failing auth by updating the variable set in pytest.ini

      env = 
            API_TOKEN=1234correct

In some class

      load_env()
      TOKEN = os.getenv('API_TOKEN')

Now in test I would like to modify its value so the authentication will fail

test_auth.py
   
   def test_it(monkeypatch):
        os.unsetenv("API_TOKEN")
        print(os.getenv('API_TOKEN')) // its still there
        monkeypatch.setenv("API_TOKEN", 1234wrong)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions