Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Sep 30, 2024
1 parent 4bb0352 commit 685708a
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/_dev/dev/tests/modelfun/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import pytest
import seaborn as sns
from dev.tests.modelfun import FIT

from boilercore.notebooks.namespaces import get_nb_ns
from dev.tests.modelfun import FIT

MODELFUN = Path("src/boilercore/stages/modelfun.ipynb").resolve()


@pytest.fixture
def ns(request) -> SimpleNamespace:
def ns() -> SimpleNamespace:
"""Namespace for the model function notebook."""
return get_nb_ns(MODELFUN.read_text(encoding="utf-8"))

Expand Down
16 changes: 12 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dev-dependencies = [
"pytest-custom-exit-code>=0.3.0",
"pytest-github-actions-annotate-failures>=0.2.0",
"pytest>=8.2.2",
"pytest-plt>=1.1.1",
]
[tool.uv.pip]
python-version = "3.11"
Expand Down Expand Up @@ -163,7 +164,14 @@ showcontent = true

[tool.pyright]
stubPath = "typings/stubs"
exclude = ["**/node_modules", "**/__pycache__", "**/.*", ".cache", "typings"]
exclude = [
"**/node_modules",
"**/__pycache__",
"**/.*",
".cache",
"typings",
"packages/cachier",
]
ignore = ["**/node_modules", "**/__pycache__", "**/.*", ".cache", "typings"]
typeCheckingMode = "strict"
# Default "true" in strict
Expand Down Expand Up @@ -263,9 +271,9 @@ reportUnusedCallResult = "none"

[tool.ruff]
cache-dir = ".cache/.ruff_cache"
extend-exclude = ["packages", "typings"]
extend-include = ["*.ipynb", "packages/_dev"]
src = ["src", "docs", "scripts", "tests"]
extend-exclude = ["typings", "packages/cachier"]
extend-include = ["*.ipynb"]
src = ["src", "docs", "scripts", "f"]
output-format = "grouped"
fix = true
preview = true
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pytest==8.2.2
pytest-cov==5.0.0
pytest-custom-exit-code==0.3.0
pytest-github-actions-annotate-failures==0.2.0
pytest-plt==1.1.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.2
Expand Down
33 changes: 32 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
from typing import Any

import pytest
import seaborn as sns
from cachier import cachier, set_default_params # pyright: ignore[reportMissingImports]
from dev.tests import EMPTY_NB
from dev.tests.modelfun import FIT

import boilercore
from boilercore.hashes import hash_args
from boilercore.models.params import Params
from boilercore.notebooks import namespaces
from boilercore.notebooks.namespaces import NO_PARAMS, get_cached_nb_ns, get_ns_attrs
from boilercore.notebooks.namespaces import (
NO_PARAMS,
get_cached_nb_ns,
get_nb_ns,
get_ns_attrs,
)
from boilercore.testing import get_session_path, unwrap_node
from boilercore.warnings import filter_boiler_warnings

MODELFUN = Path("src/boilercore/stages/modelfun.ipynb").resolve()


# Can't be session scope
@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -84,3 +93,25 @@ def cached_function(cached_function_and_cache_file): # noqa: D103
@pytest.fixture
def cache_file(cached_function_and_cache_file): # noqa: D103
return cached_function_and_cache_file[1]


@pytest.fixture
def ns() -> SimpleNamespace:
"""Namespace for the model function notebook."""
return get_nb_ns(MODELFUN.read_text(encoding="utf-8"))


@pytest.fixture
def model(params):
"""Deserialized model."""
return FIT.get_models(params.paths.models)[1]


@pytest.fixture
def plt(plt):
"""Plot."""
sns.set_theme(
context="notebook", style="whitegrid", palette="bright", font="sans-serif"
)
yield plt
plt.saveas = f"{plt.saveas[:-4]}.png"
File renamed without changes.
15 changes: 15 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 685708a

Please sign in to comment.