Skip to content

Commit

Permalink
increase coverage of log module
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Mar 6, 2017
1 parent 18d7d5d commit 89af551
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
------------------

* Get .travis.yml file and other components ready for Python 3.6.
* Increase test coverage in a few areas.

1.9.3 (2017-03-01)
------------------
Expand Down
25 changes: 25 additions & 0 deletions py/desiutil/test/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ def test_log(self):
logger.error("This is an error message.")
logger.critical("This is a critical error message.")

def test_log_with_desi_loglevel(self):
"""Test basic logging functionality with DESI_LOGLEVEL set.
"""
from os import environ
desi_level_cache = self.desi_level
for lvl in ('warning', 'foobar'):
self.desi_level = environ['DESI_LOGLEVEL'] = lvl
for level in (None, l.DEBUG, l.INFO, l.WARNING, l.ERROR):
logger = l.get_logger(level)
print("With the requested debugging level={0}:".format(level))
if self.desi_level is not None and (self.desi_level != "" ):
print(" (but overuled by env. DESI_LOGLEVEL='{0}')".format(self.desi_level))
print("--------------------------------------------------")
logger.debug("This is a debugging message.")
logger.info("This is an informational message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")
logger.critical("This is a critical error message.")
if desi_level_cache is None:
del environ['DESI_LOGLEVEL']
self.desi_level = None
else:
environ['DESI_LOGLEVEL'] = desi_level_cache
self.desi_level = desi_level_cache

def test_log_with_timestamp(self):
"""Test logging with timestamps.
"""
Expand Down

0 comments on commit 89af551

Please sign in to comment.