Skip to content

Commit

Permalink
Add session.debug to show debug-level messages (#489)
Browse files Browse the repository at this point in the history
* Add `session.debug` to show debug-level messages

A logging function to show debug-level messages.

* Add `session.debug` to show debug-level messages

Add a coverage test.
  • Loading branch information
DiddiLeija committed Oct 5, 2021
1 parent d95c57c commit a2bd140
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nox/sessions.py
Expand Up @@ -520,6 +520,10 @@ def warn(self, *args: Any, **kwargs: Any) -> None:
"""Outputs a warning during the session."""
logger.warning(*args, **kwargs)

def debug(self, *args: Any, **kwargs: Any) -> None:
"""Outputs a debug-level message during the session."""
logger.debug(*args, **kwargs)

def error(self, *args: Any) -> "_typing.NoReturn":
"""Immediately aborts the session and optionally logs an error."""
raise _SessionQuit(*args)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_sessions.py
Expand Up @@ -609,6 +609,14 @@ def test_warn(self, caplog):

assert "meep" in caplog.text

def test_debug(self, caplog):
caplog.set_level(logging.DEBUG)
session, _ = self.make_session_and_runner()

session.debug("meep")

assert "meep" in caplog.text

def test_error(self, caplog):
caplog.set_level(logging.ERROR)
session, _ = self.make_session_and_runner()
Expand Down

0 comments on commit a2bd140

Please sign in to comment.