trying to do CaptureLogOutputDuringTestsFilter (but no worky yet)

This commit is contained in:
2021-07-27 13:56:58 -05:00
committed by 3wc
parent 4e510ebb01
commit 6a587ac7fc
3 changed files with 31 additions and 16 deletions

View File

@ -22,17 +22,10 @@ class BaseTestCase(TestCase):
return self.app
def setUp(self):
self.logs_from_test = StringIO()
self.logs_handler = logging.StreamHandler(self.logs_from_test)
current_app.logger.addHandler(self.logs_handler)
pass
def tearDown(self):
#self.app.logger.removeHandler(self.logs_handler)
#logging.getLogger("asdasd1").warning(f"{self.id()} captured output:\n{self.logs_from_test.getvalue()}\n")
file_object = open('unittest-output.log', 'a')
file_object.write(f"{self.id()} captured output:\n{self.logs_from_test.getvalue()}\n")
file_object.close()
pass
def _login(self, user_email):
get_model().login(user_email)