forked from github/pelican
The default configuration for the warnings module changed some time ago so we lost the ability to detect deprecation warnings and such early. This commit sets up the test suite to redirect all warnings through our logging system. Additionally we enable DeprecationWarnings as a default and throw exceptions on all warnings related to pelican modules. This enables output of warnings related to dependencies, while letting tests only fail if the warnings are originating from pelican's source. Also adding a test to detect if warnings cause an Exception as expected.
15 lines
463 B
Python
15 lines
463 B
Python
import logging
|
|
import warnings
|
|
|
|
from pelican.log import log_warnings
|
|
|
|
# redirect warnings modulole to use logging instead
|
|
log_warnings()
|
|
|
|
# setup warnings to log DeprecationWarning's and error on
|
|
# warnings in pelican's codebase
|
|
warnings.simplefilter("default", DeprecationWarning)
|
|
warnings.filterwarnings("error", ".*", Warning, "pelican")
|
|
|
|
# Add a NullHandler to silence warning about no available handlers
|
|
logging.getLogger().addHandler(logging.NullHandler())
|