Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisNein committed Nov 26, 2023
1 parent 6cf805f commit 824a92d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/unit/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,27 @@ def test_reset_logging_level():

log.reset_logging_level(20)
b.message('test_message_4') # should be shown since logging level is info now
c.message('test_message_5') # should be shown since logging level is info now
c.message('test_message_5') # should be shown since logging level is info now

content = ''
if Path(DEFAULT_LOG_PATH).exists():
content = Path(DEFAULT_LOG_PATH).read_text()

assert (lambda message: message in content, ['test_message_1', 'test_message_4', 'test_message_5'])
assert (lambda message: message not in content, ['test_message_2', 'test_message_3'])


@pytest.mark.parametrize('msg',
['And therefore I could not continue.', ValueError('And therefore I could not continue.')])
def test_log_or_raise(msg):
try:
raise ArithmeticError('Something went wrong.')
except ArithmeticError:
with pytest.raises(Exception):
default_log().log_or_raise('message', msg)

content = ''
if Path(DEFAULT_LOG_PATH).exists():
content = Path(DEFAULT_LOG_PATH).read_text()

assert (lambda message: message in content, ['Something went wrong.', str(msg)])

0 comments on commit 824a92d

Please sign in to comment.