aboutsummaryrefslogtreecommitdiff
path: root/absl/logging/tests
diff options
context:
space:
mode:
authorGregory P. Smith <gps@google.com>2018-07-18 16:46:59 -0700
committerCopybara-Service <copybara-piper@google.com>2018-07-18 16:47:13 -0700
commit1be0f546b64c4da266880240b51e4d2d4c0eb003 (patch)
treec471979ffdafcdd4cf8411ffc66920738e80b6c0 /absl/logging/tests
parent607faa20a3b4c8c09ef8664d3615aca3f0dd9aae (diff)
downloadabsl-py-1be0f546b64c4da266880240b51e4d2d4c0eb003.tar.gz
Clarify the findCaller() docstring around the stack_info arg and the different return value behavior between Python 2 and Python 3.
This also enables use of the stack_info parameter on Python 2 if anyone wants it. The Python 2 base class lacks the feature entirely, so supporting it as an absl specific addition seems reasonable. https://github.com/abseil/abseil-py/issues/62 PiperOrigin-RevId: 205160095
Diffstat (limited to 'absl/logging/tests')
-rw-r--r--absl/logging/tests/logging_test.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/absl/logging/tests/logging_test.py b/absl/logging/tests/logging_test.py
index ad0e214..ea68a36 100644
--- a/absl/logging/tests/logging_test.py
+++ b/absl/logging/tests/logging_test.py
@@ -442,7 +442,6 @@ class ABSLLoggerTest(absltest.TestCase):
self.assertEqual(expected_name, self.logger.findCaller()[2])
self.assertEqual(expected_frame_lineno, self.logger.findCaller()[1])
- @unittest.skipIf(six.PY2, 'stack_info is only supported in Python 3.')
def test_find_caller_stack_info(self):
self.set_up_mock_frames()
self.logger.register_frame_to_skip('myfile.py', 'Method1')
@@ -452,6 +451,13 @@ class ABSLLoggerTest(absltest.TestCase):
self.logger.findCaller(stack_info=True))
print_stack.assert_called_once()
+ @unittest.skipIf(six.PY3, 'Testing Python 2 specific behavior.')
+ def test_find_caller_python2(self):
+ """Ensure that we only return three items for base class compatibility."""
+ self.set_up_mock_frames()
+ self.logger.register_frame_to_skip('myfile.py', 'Method1')
+ self.assertEqual(('myfile.py', 125, 'Method2'), self.logger.findCaller())
+
def test_critical(self):
with mock.patch.object(self.logger, 'log'):
self.logger.critical(self.message)