Skip to content

Commit

Permalink
Update flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin committed May 14, 2024
1 parent ba62b63 commit 30a4680
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dev = [
"ruff",
]
tests = [
"flaky",
"pytest-asyncio>=0.18.2,!=0.22.0,<0.23.0",
"pytest-env>=0.8,<2.0",
"pytest-rerunfailures>=10,<14",
Expand Down
6 changes: 3 additions & 3 deletions tests/ai/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ def test_return_index(self):
assert result == 1

class TestExamples:
@pytest.mark.flaky(max_runs=3)
@pytest.mark.flaky(reruns=3)
async def test_hogwarts_sorting_hat(self):
description = "Brave, daring, chivalrous, and sometimes a bit reckless -- just like Harry Potter."
description = "Brave, daring, chivalrous -- it's Harry Potter!"

house = marvin.classify(
description,
labels=["Gryffindor", "Hufflepuff", "Ravenclaw", "Slytherin"],
instructions="Select the best house for the student",
instructions="You're the sorting hat. Select the house for the student",
)

assert house == "Gryffindor"
Expand Down
2 changes: 1 addition & 1 deletion tests/ai/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_extract_names(self):
)
assert result == ["John", "Mary", "Bob"]

@pytest.mark.flaky(max_runs=3)
@pytest.mark.flaky(reruns=3)
def test_float_to_int(self):
# gpt 3.5 sometimes struggles with this test, marked as flaky
# pydantic no longer casts floats to ints, but gpt-3.5 assumes it's
Expand Down
2 changes: 1 addition & 1 deletion tests/ai/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RentalHistory(BaseModel):
"""
)

@pytest.mark.flaky(max_runs=3)
@pytest.mark.flaky(reruns=3)
def test_resume(self):
class Experience(BaseModel):
technology: str
Expand Down
2 changes: 1 addition & 1 deletion tests/ai/vision/test_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def use_gpt4o_for_all_tests(gpt_4):
pass


@pytest.mark.flaky(max_runs=2)
@pytest.mark.flaky(reruns=2)
class TestVisionCaption:
def test_ny(self):
img = marvin.Image(
Expand Down
4 changes: 2 additions & 2 deletions tests/ai/vision/test_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def use_gpt4o_for_all_tests(gpt_4):
pass


@pytest.mark.flaky(max_runs=3)
@pytest.mark.flaky(reruns=3)
class TestVisionCast:
def test_cast_ny(self):
img = marvin.Image(
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_map(self):
assert_locations_equal(result[0], Location(city="New York", state="NY"))
assert_locations_equal(result[1], Location(city="Washington", state="DC"))

@pytest.mark.flaky(max_runs=2)
@pytest.mark.flaky(reruns=2)
async def test_async_map(self):
ny = marvin.Image(
"https://images.unsplash.com/photo-1568515387631-8b650bbcdb90"
Expand Down
2 changes: 1 addition & 1 deletion tests/ai/vision/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def use_gpt4o_for_all_tests(gpt_4):
pass


@pytest.mark.flaky(max_runs=2)
@pytest.mark.flaky(reruns=2)
class TestVisionClassify:
def test_ny_image_input(self):
img = marvin.Image(
Expand Down
4 changes: 2 additions & 2 deletions tests/ai/vision/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def use_gpt4o_for_all_tests(gpt_4):
pass


@pytest.mark.flaky(max_runs=2)
@pytest.mark.flaky(reruns=2)
class TestVisionExtract:
def test_ny_image_input(self):
img = marvin.Image(
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_two_cities(self):
assert_locations_equal(locations[0], Location(city="New York", state="NY"))
assert_locations_equal(locations[1], Location(city="Washington", state="DC"))

@pytest.mark.flaky(max_runs=3)
@pytest.mark.flaky(reruns=3)
def test_dog(self):
class Animal(BaseModel, frozen=True):
type: Literal["cat", "dog", "bird", "frog", "horse", "pig"]
Expand Down
2 changes: 1 addition & 1 deletion tests/beta/assistants/test_assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_code_interpreter(self):
assert 85 <= output <= 95


@pytest.mark.flaky(max_runs=2)
@pytest.mark.flaky(reruns=2)
class TestLifeCycle:
@patch.object(client.beta.assistants, "delete", wraps=client.beta.assistants.delete)
@patch.object(client.beta.assistants, "create", wraps=client.beta.assistants.create)
Expand Down

0 comments on commit 30a4680

Please sign in to comment.