Skip to content

Commit

Permalink
monkeypatch delenv
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Sep 18, 2023
1 parent 3e3031b commit 481a686
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def test_init_with_parameters(self):
assert embedder.suffix == "suffix"

@pytest.mark.unit
def test_init_fail_wo_api_key(self):
def test_init_fail_wo_api_key(self, monkeypatch):
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
with pytest.raises(ValueError, match="OpenAITextEmbedder expects an OpenAI API key"):
OpenAITextEmbedder()

Expand Down Expand Up @@ -106,7 +107,8 @@ def test_from_dict(self, monkeypatch):
assert component.suffix == "suffix"

@pytest.mark.unit
def test_from_dict_fail_wo_env_var(self):
def test_from_dict_fail_wo_env_var(self, monkeypatch):
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
data = {
"type": "OpenAITextEmbedder",
"init_parameters": {
Expand Down

0 comments on commit 481a686

Please sign in to comment.