I am trying to add logging to my pytest tests and everything is going fine except the fact, that every other testrun's log re-writes all the precious information.
Here is my pytest.ini file:
log_file = my.log
log_file_level = DEBUG
log_file_format = %(levelname)s %(asctime)s - %(message)s (%(filename)s:%(lineno)s)
log_file_date_format=%Y-%m-%d %H:%M:%S
Here is my test code:
import os
class TestLog:
def test_log_1(self):
logging.info('everything is okay')
output = 2
assert output == 2, 'everything is okay'
def test_log_2(self):
output = 0
logging.info(f'test params: {output}')
try:
assert output == 2, 'everything is okay'
except AssertionError:
logging.error(f"'everything is not okay'")
raise AssertionError
I tried to add logging.basicConfig(filemode = "a") but it was no help.
Any help would be appreciated