mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 09:00:00 -06:00
Add suppress_logging()
As a helper for C/C++ domain, this adds suppress_logging(). It works as a context manager and suppresses all loggings during the context temporarily.
This commit is contained in:
1 parent
385f7ed40e
commit
2f33b9376b
2 files changed
+36
-5
No files matched your search
@@ -233,6 +233,20 @@ def test_warning_location(app, status, warning):
|
||||
assert colorize('red', 'WARNING: message7') in warning.getvalue()
|
||||
|
||||
|
||||
def test_suppress_logging(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message1')
|
||||
with logging.suppress_logging():
|
||||
logger.warning('message2')
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: message2' not in warning.getvalue()
|
||||
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: message2' not in warning.getvalue()
|
||||
|
||||
|
||||
def test_pending_warnings(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
Reference in new issue
Block a user