Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jun 12, 2024
1 parent 72a0dea commit 19bfa80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/microsim/cosem/_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from contextlib import suppress

try:
import boto3
Expand Down Expand Up @@ -107,10 +108,11 @@ def _collect_fields(model: type[BaseModel]) -> Iterator[str | tuple]:
"""Used in model_query to recursively collect fields from a model."""
for field, info in model.model_fields.items():
args = get_args(info.annotation)
if args and isinstance(args[0], type) and issubclass(args[0], BaseModel):
anno: Any = args[0]
else:
anno = info.annotation
anno: Any = info.annotation
with suppress(TypeError):
if args and isinstance(args[0], type) and issubclass(args[0], BaseModel):
anno = args[0]

if isinstance(anno, type) and issubclass(anno, BaseModel):
name = anno.__name__
if name.startswith("Cosem"):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from microsim import util

EXAMPLE_DIR = Path(__file__).parent.parent / "examples/"
skip = {"illum_widget", "fftconv_bench"}
examples = [
Expand All @@ -15,8 +17,9 @@

@pytest.mark.usefixtures("mpl_show_patch")
@pytest.mark.parametrize("fpath", examples, ids=lambda x: x.name)
def test_examples(fpath: Path, tmp_path: Path) -> None:
def test_examples(fpath: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""Test that all of our examples are still working without warnings."""
monkeypatch.setattr(util, "ndview", lambda *args, **kwargs: None)
if fpath.suffix == ".ipynb":
nb = json.loads(fpath.read_text())

Expand Down

0 comments on commit 19bfa80

Please sign in to comment.