Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Waiting to run
Test / Core Tests (push) Waiting to run
Test / Offline Coverage Tests (Python 3.10) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.11) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.12) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.13) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.9) (push) Waiting to run
Test / Full Coverage (Python 3.11) (push) Waiting to run
Test / Core Provider Tests (OpenAI) (push) Blocked by required conditions
Test / Core Provider Tests (Anthropic) (push) Blocked by required conditions
Test / Core Provider Tests (Google) (push) Blocked by required conditions
Test / Core Provider Tests (Other) (push) Blocked by required conditions
Test / Anthropic Tests (push) Blocked by required conditions
Test / Gemini Tests (push) Blocked by required conditions
Test / Google GenAI Tests (push) Blocked by required conditions
Test / Vertex AI Tests (push) Blocked by required conditions
Test / OpenAI Tests (push) Blocked by required conditions
Test / Writer Tests (push) Blocked by required conditions
Test / Auto Client Tests (push) Blocked by required conditions
ty / type-check (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

81 lines
1.8 KiB
Python

import functools
from openai import AsyncOpenAI, OpenAI
import pytest
import instructor
from instructor.utils import is_async
def test_patch_completes_successfully():
with OpenAI(api_key="test-key") as client:
instructor.patch(client)
@pytest.mark.asyncio
async def test_apatch_completes_successfully():
async with AsyncOpenAI(api_key="test-key") as client:
with pytest.warns(
DeprecationWarning, match="apatch is deprecated, use patch instead"
):
instructor.apatch(client)
def test_is_async_returns_true_if_function_is_async():
async def async_function():
pass
assert is_async(async_function) is True
def test_is_async_returns_false_if_function_is_not_async():
def sync_function():
pass
assert is_async(sync_function) is False
def test_is_async_returns_true_if_wrapped_function_is_async():
async def async_function():
pass
@functools.wraps(async_function)
def wrapped_function():
pass
assert is_async(wrapped_function) is True
def test_is_async_returns_true_if_double_wrapped_function_is_async():
async def async_function():
pass
@functools.wraps(async_function)
def wrapped_function():
pass
@functools.wraps(wrapped_function)
def double_wrapped_function():
pass
assert is_async(double_wrapped_function) is True
def test_is_async_returns_true_if_triple_wrapped_function_is_async():
async def async_function():
pass
@functools.wraps(async_function)
def wrapped_function():
pass
@functools.wraps(wrapped_function)
def double_wrapped_function():
pass
@functools.wraps(double_wrapped_function)
def triple_wrapped_function():
pass
assert is_async(triple_wrapped_function) is True