• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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 tensorflow.python.framework.constant_op."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21from absl.testing import parameterized
22
23from tensorflow.python.framework import constant_op
24from tensorflow.python.framework import dtypes
25from tensorflow.python.framework import ops
26from tensorflow.python.platform import test
27
28
29class ConstantOpTest(test.TestCase, parameterized.TestCase):
30
31  @parameterized.parameters(
32      dtypes.bfloat16,
33      dtypes.complex128,
34      dtypes.complex64,
35      dtypes.double,
36      dtypes.float16,
37      dtypes.float32,
38      dtypes.float64,
39      dtypes.half,
40      dtypes.int16,
41      dtypes.int32,
42      dtypes.int64,
43      dtypes.int8,
44      dtypes.qint16,
45      dtypes.qint32,
46      dtypes.qint8,
47      dtypes.quint16,
48      dtypes.quint8,
49      dtypes.uint16,
50      dtypes.uint32,
51      dtypes.uint64,
52      dtypes.uint8,
53  )
54  def test_convert_string_to_number(self, dtype):
55    with self.assertRaises(TypeError):
56      constant_op.constant("hello", dtype)
57
58
59if __name__ == "__main__":
60  ops.enable_eager_execution()
61  test.main()
62