Skip to content

Commit

Permalink
fix tests that call get_logger()
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Dec 12, 2017
1 parent ca14fe7 commit ab0cdd0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions py/desiutil/test/test_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def test_walk_error(self):
raise OSError(2, 'File not found', 'foo.txt')
except OSError as e:
walk_error(e)
calls = [call.error("[Errno 2] File not found: 'foo.txt'")]
calls = [call.setLevel(20),
call.error("[Errno 2] File not found: 'foo.txt'")]
self.assertListEqual(mock.mock_calls, calls)
with patch('desiutil.log.desi_logger') as mock:
try:
raise OSError(2, 'File not found', 'foo.txt', None, 'bar.txt')
except OSError as e:
walk_error(e)
calls = [call.error("[Errno 2] File not found: 'foo.txt' -> " +
calls = [call.setLevel(20),
call.error("[Errno 2] File not found: 'foo.txt' -> " +
"'bar.txt'")]
self.assertListEqual(mock.mock_calls, calls)

Expand Down Expand Up @@ -108,7 +110,8 @@ def test_scan_file(self):
#
# Simulate a simple file.
#
calls = [call.debug("os.stat('{0}')".format(fd)),
calls = [call.setLevel(20),
call.debug("os.stat('{0}')".format(fd)),
call.warning("{0} does not have correct group id!".format(fd))]
with patch('desiutil.log.desi_logger') as mock_log:
with patch.dict('sys.modules', {'os': mock_os,
Expand All @@ -125,7 +128,8 @@ def test_scan_file(self):
#
# Simulate an internal link.
#
calls = [call.debug("os.stat('{0}')".format(fd)),
calls = [call.setLevel(20),
call.debug("os.stat('{0}')".format(fd)),
call.warning("{0} does not have correct group id!".format(fd)),
call.debug("os.lstat('{0}')".format(fd)),
call.warning("{0} does not have correct group id!".format(fd)),
Expand All @@ -150,7 +154,8 @@ def test_scan_file(self):
#
# Simulate an external link.
#
calls = [call.debug("os.stat('{0}')".format(fd)),
calls = [call.setLevel(20),
call.debug("os.stat('{0}')".format(fd)),
call.warning("{0} does not have correct group id!".format(fd)),
call.debug("os.lstat('{0}')".format(fd)),
call.warning("{0} does not have correct group id!".format(fd)),
Expand Down

0 comments on commit ab0cdd0

Please sign in to comment.