aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/util/deprecation_test.py
diff options
context:
space:
mode:
authorGravatar Martin Wicke <wicke@google.com>2017-05-23 09:27:19 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-23 09:32:20 -0700
commit325fc2330f4e527b394456ce1d821f2c73b1e7a2 (patch)
tree468ea5a63fb44465e55971a62889f444558c4708 /tensorflow/python/util/deprecation_test.py
parent48718981d2018a44d9f6ab4f3bf675b22353670b (diff)
Make a silencing context manager for deprecations and use it.
PiperOrigin-RevId: 156870702
Diffstat (limited to 'tensorflow/python/util/deprecation_test.py')
-rw-r--r--tensorflow/python/util/deprecation_test.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tensorflow/python/util/deprecation_test.py b/tensorflow/python/util/deprecation_test.py
index cce0bb1b4e..e2d9a594a3 100644
--- a/tensorflow/python/util/deprecation_test.py
+++ b/tensorflow/python/util/deprecation_test.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""tensor_util tests."""
+"""Deprecation tests."""
# pylint: disable=unused-import
from __future__ import absolute_import
@@ -26,6 +26,25 @@ from tensorflow.python.util import deprecation
class DeprecationTest(test.TestCase):
+ @test.mock.patch.object(logging, "warning", autospec=True)
+ def test_silence(self, mock_warning):
+ date = "2016-07-04"
+ instructions = "This is how you update..."
+
+ @deprecation.deprecated(date, instructions)
+ def _fn():
+ pass
+
+ _fn()
+ self.assertEqual(1, mock_warning.call_count)
+
+ with deprecation.silence():
+ _fn()
+ self.assertEqual(1, mock_warning.call_count)
+
+ _fn()
+ self.assertEqual(2, mock_warning.call_count)
+
def _assert_subset(self, expected_subset, actual_set):
self.assertTrue(
actual_set.issuperset(expected_subset),