Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
delete the test log if test passes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Cowling committed Oct 25, 2013
1 parent acbdf9b commit 777b865
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/core/test_json_logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hamcrest import assert_that, has_entries
# import os
import os
import logging
import json
from backdrop.core import log_handler
Expand All @@ -14,18 +14,17 @@ def setUp(self):
self.logger = self.app.logger
self.app.config['LOG_LEVEL'] = logging.DEBUG

# def tearDown(self):
# delete the log
# os.remove('log/json_test.log.json')

def test_json_log_written_when_logger_called(self):

log_handler.set_up_logging(self.app, 'json_test', 'json_test')
# handler = logging.FileHandler('/var/log/myapp.log')
self.logger.info('Writing out JSON formatted logs m8')

with open('log/json_test.log.json') as log_file:
data = json.loads(log_file.readlines()[-1])

assert_that(data, has_entries({
'@message': 'Writing out JSON formatted logs m8'
}))

# Only remove file if assertion passes
os.remove('log/json_test.log.json')

0 comments on commit 777b865

Please sign in to comment.