Suppress factory_boy captured logging information?
Asked Answered
F

1

11

Is there any way to suppress (i.e. hide) the captured logging information block factory boy generates when a test fails or generates an error? I'm talking about this:

SomeError: you encountered an error
----------- >> begin captured loggin << -----------
... DEBUG information
----------- >> end captured loggin << -------------

---------------------------------------------------
Ran 1 test...

Often times, this information isn't relevant or necessary to solve the problem and it's just a lot of stuff I have to scroll up past to see what caused the error.

Thanks.

Fogle answered 3/10, 2013 at 15:35 Comment(0)
C
25

You can change the factory_boy logging level with:

import logging
logging.getLogger("factory").setLevel(logging.WARN)

Replacing WARN with whatever level you want. I don't know where to put this in a Django environment, but you can put this in your test file or some global initializer.

This should suppress any logging except actual factory_boy errors & warnings.

Weird default, since factory_boy debugging is rarely helpful and is incredibly verbose.

Clad answered 11/10, 2013 at 17:50 Comment(1)
Thanks Jim! It worked like a charm. This will save me miles of scrolling.Fogle

© 2022 - 2024 — McMap. All rights reserved.