logging: move log_file_handler cleanup from sessionend to unconfigure

It is set-up in configure, so match it.
This commit is contained in:
Ran Benita 2020-05-17 14:58:04 +03:00
parent 43c465c9bf
commit bd5e3f042d
1 changed files with 6 additions and 4 deletions

View File

@ -678,10 +678,6 @@ class LoggingPlugin:
with catching_logs(self.log_file_handler, level=self.log_file_level):
yield
# Close the FileHandler explicitly.
# (logging.shutdown might have lost the weakref?!)
self.log_file_handler.close()
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_sessionstart(self):
self.log_cli_handler.set_when("sessionstart")
@ -706,6 +702,12 @@ class LoggingPlugin:
with catching_logs(self.log_file_handler, level=self.log_file_level):
yield # run all the tests
@pytest.hookimpl
def pytest_unconfigure(self):
# Close the FileHandler explicitly.
# (logging.shutdown might have lost the weakref?!)
self.log_file_handler.close()
class _LiveLoggingStreamHandler(logging.StreamHandler):
"""