You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#3#4https://docs.python.org/3/library/unittest.mock.html#where-to-patch
- Mock the root logger object directly: The project previously had a
`mock_logger` pytest fixture in conftest.py that instantiated a root
logger with `logging.getLogger()`. The individual log level attributes
were then patched with `mocker.patch.object(logger, "debug")`. This
was problematic, because Mypy thought that the logger didn't have the
attributes, requiring many `# type: ignore[attr-defined]` comments.
Instead of `logging.getLogger()`, the root logger object itself will
be directly patched whenever it is used for testing.
- Remove `# type: ignore[attr-defined]` Mypy comments: now that the
`mock_logger` is a proper `MockerFixture`, pytest and pytest-mock
will create the necessary attributes automatically.
- Correct module spec syntax in `set_app_module()`: importlib needs the
module path without the app instance name at the end. The way this
function was written before, importlib was just returning `None`.
inboard should be able to find the app module before continuing, or
raise an `ImportError` exception if module spec is not created.
- Move error messages to error log level instead of debug: makes more
sense for errors to be logged as errors
- Add `e.__class__.__name__` to log messages when exceptions are raised:
helps to have the exception class name
0 commit comments