• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""Tests for forward and backwards compatibility utilties."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21from tensorflow.python.compat import v2_compat
22from tensorflow.python.framework import constant_op
23from tensorflow.python.framework import ops
24from tensorflow.python.platform import test
25
26
27class DisableV2BehaviorTest(test.TestCase):
28
29  def test_basic(self):
30    t = constant_op.constant([1, 2, 3])  # creates a hidden context
31    self.assertTrue(isinstance(t, ops.EagerTensor))
32    v2_compat.disable_v2_behavior()
33    t = constant_op.constant([1, 2, 3])
34    self.assertFalse(isinstance(t, ops.EagerTensor))
35
36
37if __name__ == '__main__':
38  v2_compat.enable_v2_behavior()
39  test.main()
40