Skip to content

Commit

Permalink
feat: additional coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Sep 22, 2024
1 parent 4f12367 commit fef9899
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions litestar/contrib/sqlalchemy/repository/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def __getattr__(attr_name: str) -> object:
)

warn_deprecation(
deprecated_name=f"litestar.contrib.sqlalchemy.repository.{attr_name}",
deprecated_name=f"litestar.contrib.sqlalchemy.repository._util.{attr_name}",
version="2.12",
kind="import",
removal_in="3.0",
info=f"importing {attr_name} from 'litestar.contrib.sqlalchemy.repository' is deprecated, please "
info=f"importing {attr_name} from 'litestar.contrib.sqlalchemy.repository._util' is deprecated, please "
f"import it from 'litestar.plugins.sqlalchemy.repository' instead",
)
value = globals()[attr_name] = locals()[attr_name]
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_contrib/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,19 @@ def test_deprecated_sqlalchemy_plugins_init_config_sync_handlers() -> None:
match="importing autocommit_before_send_handler from 'litestar.contrib.sqlalchemy.plugins.init.config.sync' is deprecated",
):
from litestar.contrib.sqlalchemy.plugins.init.config.sync import autocommit_before_send_handler


def test_deprecated_sqlalchemy_repository_util_imports() -> None:
purge_module(["litestar.contrib.sqlalchemy.repository._util"], __file__)
with pytest.warns(
DeprecationWarning,
match="importing wrap_sqlalchemy_exception from 'litestar.contrib.sqlalchemy.repository._util' is deprecated",
):
from litestar.contrib.sqlalchemy.repository._util import wrap_sqlalchemy_exception

purge_module(["litestar.contrib.sqlalchemy.repository._util"], __file__)
with pytest.warns(
DeprecationWarning,
match="importing get_instrumented_attr from 'litestar.contrib.sqlalchemy.repository._util' is deprecated",
):
from litestar.contrib.sqlalchemy.repository._util import get_instrumented_attr

0 comments on commit fef9899

Please sign in to comment.