Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Dec 22, 2024
1 parent a4fc5d8 commit b381e35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
9 changes: 2 additions & 7 deletions examples/pydantic_ai_examples/stream_whales.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
uv run -m pydantic_ai_examples.whales
"""

from typing import Annotated, NotRequired, TypedDict
from typing import Annotated

import devtools
import logfire
from pydantic import Field, ValidationError
from rich.console import Console
from rich.live import Live
from rich.table import Table
from typing_extensions import NotRequired, TypedDict

from pydantic_ai import Agent

Expand All @@ -41,11 +41,6 @@ class Whale(TypedDict):
agent = Agent('openai:gpt-4', result_type=list[Whale])


def check_validation_error(e: ValidationError) -> bool:
devtools.debug(e.errors())
return False


async def main():
console = Console()
with Live('\n' * 36, console=console) as live:
Expand Down
23 changes: 14 additions & 9 deletions tests/import_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
"""

import os
import sys
from pathlib import Path

os.environ.update(OPENAI_API_KEY='fake-key', GEMINI_API_KEY='fake-key', GROQ_API_KEY='fake-key')
if sys.version_info < (3, 11):
print('Skipping import_examples.py because it requires Python 3.11+')
else:
os.environ.update(OPENAI_API_KEY='fake-key', GEMINI_API_KEY='fake-key', GROQ_API_KEY='fake-key')

examples_dir = Path(__file__).parent.parent / 'examples' / 'pydantic_ai_examples'
assert examples_dir.is_dir(), f'No examples directory found at {examples_dir}'
count = 0
for example in examples_dir.glob('*.py'):
print(f'Importing {example.stem}...')
__import__(f'pydantic_ai_examples.{example.stem}')
count += 1
examples_dir = Path(__file__).parent.parent / 'examples' / 'pydantic_ai_examples'
assert examples_dir.is_dir(), f'No examples directory found at {examples_dir}'
count = 0
for example in examples_dir.glob('*.py'):
print(f'Importing {example.stem}...')
__import__(f'pydantic_ai_examples.{example.stem}')
count += 1

assert count > 0, 'No examples found'
print(f'Imported {count} examples')
assert count > 5, 'No examples found'

0 comments on commit b381e35

Please sign in to comment.