Nelly-Barret / BETTER-fairificator

The fairification tools for BETTER project.
https://www.better-health-project.eu/
0 stars 0 forks source link

Do not generate a log file when running tests #35

Open Nelly-Barret opened 3 weeks ago

Nelly-Barret commented 3 weeks ago

As of know, whenever I run the code (src or tests), a log file is generated and put next to the "temporary" files.

This is annoying for tests and a bit useless, so I should create those log files only when running src.

Nelly-Barret commented 2 weeks ago

I could kind of do it by removing the FileHandler in the logging (thus, only the StreamHandler remains) but then, Python complains about an unclosed file because the logging is initialized before the test starts so the logging file is).

Taking a look at: https://docs.python.org/3/library/logging.html#logging.basicConfig, I do not see how to say "when to print log" in the BasicConfig constructor.

To be seen

Nelly-Barret commented 2 weeks ago

Easy solution: use print instead of log.info!

Nelly-Barret commented 2 weeks ago

This still creates the log file... because tested classes still print using log.info and log.debug

Check this: https://betterstack.com/community/questions/how-to-disable-logging-when-running-tests-in-python/