How can I disable logging while running unit tests in Python Django?

后端 未结 15 816
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 09:50

I am using a simple unit test based test runner to test my Django application.

My application itself is configured to use a basic logger in settings.py using:

<
15条回答
  •  被撕碎了的回忆
    2020-12-07 10:42

    logging.disable(logging.CRITICAL)
    

    will disable all logging calls with levels less severe than or equal to CRITICAL. Logging can be re-enabled with

    logging.disable(logging.NOTSET)
    

提交回复
热议问题