Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 6c7dc97

Browse files
committed
Use monkeypatch for environment variable test
1 parent 7021a72 commit 6c7dc97

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

alchemy_sdk_py/evm_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import requests
33
from dotenv import load_dotenv
44
from typing import List, Optional, Union
5-
from utils import HexIntStringNumber
5+
from .utils import HexIntStringNumber
66
from .errors import NO_API_KEY_ERROR
77
from .networks import Network
88

tests/integration/test_alchemy_setup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from alchemy_sdk_py import Alchemy
21
import os
32
import pytest
3+
from alchemy_sdk_py import Alchemy
4+
from _pytest.monkeypatch import MonkeyPatch
45

56

67
def test_initialize_empty_network(dummy_api_key, mock_env_missing):
@@ -38,10 +39,8 @@ def test_api_key_property(dummy_api_key):
3839
assert alchemy.key == dummy_api_key
3940

4041

41-
def test_key_with_environment_variable():
42+
def test_key_with_environment_variable(monkeypatch: MonkeyPatch):
4243
test_key = "test_key"
43-
original_value = os.environ["ALCHEMY_API_KEY"]
44-
os.environ["ALCHEMY_API_KEY"] = test_key
44+
monkeypatch.setenv("ALCHEMY_API_KEY", test_key)
4545
alchemy = Alchemy()
4646
assert alchemy.key == test_key
47-
os.environ["ALCHEMY_API_KEY"] = original_value

0 commit comments

Comments
 (0)