Skip to content

Commit

Permalink
parametrize test and test warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanSoley committed Aug 12, 2024
1 parent 2076258 commit 6ca8c77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rubicon_ml/domain/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
self.id = str(uuid.uuid4())

if kwargs: # replaces `dataclass` behavior of erroring on unexpected kwargs
LOGGER.warn(
LOGGER.warning(
f"{self.__class__.__name__}.__init__() got an unexpected keyword "
f"argument(s): `{'`, `'.join([key for key in kwargs])}`"
)
12 changes: 10 additions & 2 deletions tests/unit/domain/test_domain.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest import mock

import pytest

from rubicon_ml.domain.project import Project
Expand All @@ -8,9 +10,15 @@
[(Project, {"name": "test_domain_extra_kwargs"})],
)
def test_domain_extra_kwargs(domain_cls, required_kwargs):
domain = domain_cls(extra="extra", **required_kwargs)
with mock.patch(
f"rubicon_ml.domain.{domain_cls.__name__.lower()}.LOGGER.warning"
) as logger_warning:
domain = domain_cls(extra="extra", **required_kwargs)

assert "extra" not in domain.__dict__
logger_warning.assert_called_once_with(
f"{domain_cls.__name__}.__init__() got an unexpected keyword argument(s): `extra`",
)

assert "extra" not in domain.__dict__
for key, value in required_kwargs.items():
assert getattr(domain, key) == value

0 comments on commit 6ca8c77

Please sign in to comment.