diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-09-20 15:37:03 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-20 15:40:35 -0700 |
commit | d78b3484d4b98790c2d3a7c0d861487e2fcdefdf (patch) | |
tree | 8833ff4965934b77e48832c6e88fc1add421b7bf /tensorflow | |
parent | 1d1ec99bd3b322ea35a2d3d0eb754589ec2fd512 (diff) |
This CL moves the tf.print logging level tests that are sensitive to OS & environment configurations to a separate test target, and disables running them on Windows.
PiperOrigin-RevId: 213895372
Diffstat (limited to 'tensorflow')
-rw-r--r-- | tensorflow/python/kernel_tests/BUILD | 15 | ||||
-rw-r--r-- | tensorflow/python/kernel_tests/logging_ops_logging_level_test.py | 70 | ||||
-rw-r--r-- | tensorflow/python/kernel_tests/logging_ops_test.py | 3 |
3 files changed, 85 insertions, 3 deletions
diff --git a/tensorflow/python/kernel_tests/BUILD b/tensorflow/python/kernel_tests/BUILD index 5f93682de7..17831fa5cb 100644 --- a/tensorflow/python/kernel_tests/BUILD +++ b/tensorflow/python/kernel_tests/BUILD @@ -538,6 +538,21 @@ tf_py_test( ) tf_py_test( + name = "logging_ops_logging_level_test", + size = "small", + srcs = ["logging_ops_logging_level_test.py"], + additional_deps = [ + "//tensorflow/python:client_testlib", + "//tensorflow/python:framework_for_generated_wrappers", + "//tensorflow/python:framework_test_lib", + "//tensorflow/python:logging_ops", + ], + tags = [ + "no_windows", + ], +) + +tf_py_test( name = "logging_ops_test", size = "small", srcs = ["logging_ops_test.py"], diff --git a/tensorflow/python/kernel_tests/logging_ops_logging_level_test.py b/tensorflow/python/kernel_tests/logging_ops_logging_level_test.py new file mode 100644 index 0000000000..252090b7bd --- /dev/null +++ b/tensorflow/python/kernel_tests/logging_ops_logging_level_test.py @@ -0,0 +1,70 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Tests for tensorflow.kernels.logging_ops.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import sys + +from tensorflow.python.framework import test_util +from tensorflow.python.ops import logging_ops +from tensorflow.python.ops import math_ops +from tensorflow.python.platform import test +from tensorflow.python.platform import tf_logging + + +class PrintV2LoggingLevelTest(test.TestCase): + + @test_util.run_in_graph_and_eager_modes() + def testPrintOneTensorLogInfo(self): + with self.test_session(): + tensor = math_ops.range(10) + with self.captureWritesToStream(sys.stderr) as printed: + print_op = logging_ops.print_v2( + tensor, output_stream=tf_logging.info) + self.evaluate(print_op) + self.assertTrue("I" in printed.contents()) + expected = "[0 1 2 ... 7 8 9]" + self.assertTrue(expected in printed.contents()) + + @test_util.run_in_graph_and_eager_modes() + def testPrintOneTensorLogWarning(self): + with self.test_session(): + tensor = math_ops.range(10) + with self.captureWritesToStream(sys.stderr) as printed: + print_op = logging_ops.print_v2( + tensor, output_stream=tf_logging.warning) + self.evaluate(print_op) + self.assertTrue("W" in printed.contents()) + expected = "[0 1 2 ... 7 8 9]" + self.assertTrue(expected in printed.contents()) + + @test_util.run_in_graph_and_eager_modes() + def testPrintOneTensorLogError(self): + with self.test_session(): + tensor = math_ops.range(10) + with self.captureWritesToStream(sys.stderr) as printed: + print_op = logging_ops.print_v2( + tensor, output_stream=tf_logging.error) + self.evaluate(print_op) + self.assertTrue("E" in printed.contents()) + expected = "[0 1 2 ... 7 8 9]" + self.assertTrue(expected in printed.contents()) + + +if __name__ == "__main__": + test.main() diff --git a/tensorflow/python/kernel_tests/logging_ops_test.py b/tensorflow/python/kernel_tests/logging_ops_test.py index 79fe9de62f..cf0beba3c3 100644 --- a/tensorflow/python/kernel_tests/logging_ops_test.py +++ b/tensorflow/python/kernel_tests/logging_ops_test.py @@ -280,7 +280,6 @@ class PrintV2Test(test.TestCase): print_op = logging_ops.print_v2( tensor, output_stream=tf_logging.info) self.evaluate(print_op) - self.assertTrue("I" in printed.contents()) expected = "[0 1 2 ... 7 8 9]" self.assertTrue(expected in printed.contents()) @@ -292,7 +291,6 @@ class PrintV2Test(test.TestCase): print_op = logging_ops.print_v2( tensor, output_stream=tf_logging.warning) self.evaluate(print_op) - self.assertTrue("W" in printed.contents()) expected = "[0 1 2 ... 7 8 9]" self.assertTrue(expected in printed.contents()) @@ -304,7 +302,6 @@ class PrintV2Test(test.TestCase): print_op = logging_ops.print_v2( tensor, output_stream=tf_logging.error) self.evaluate(print_op) - self.assertTrue("E" in printed.contents()) expected = "[0 1 2 ... 7 8 9]" self.assertTrue(expected in printed.contents()) |