diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-09-10 14:37:06 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-10 15:04:14 -0700 |
commit | b828f89263e054bfa7c7a808cab1506834ab906d (patch) | |
tree | e31816a6850d177306f19ee8670e0836060fcfc9 /tensorflow/contrib/framework | |
parent | acf0ee82092727afc2067316982407cf5e496f75 (diff) |
Move from deprecated self.test_session() to self.cached_session().
self.test_session() has been deprecated in 9962eb5e84b15e309410071b06c2ed2d6148ed44 as its name confuses readers of the test. Moving to cached_session() instead which is more explicit about:
* the fact that the session may be reused.
* the session is not closed even when doing a "with self.test_session()" statement.
PiperOrigin-RevId: 212336464
Diffstat (limited to 'tensorflow/contrib/framework')
-rw-r--r-- | tensorflow/contrib/framework/python/framework/checkpoint_utils_test.py | 18 | ||||
-rw-r--r-- | tensorflow/contrib/framework/python/framework/tensor_util_test.py | 20 |
2 files changed, 19 insertions, 19 deletions
diff --git a/tensorflow/contrib/framework/python/framework/checkpoint_utils_test.py b/tensorflow/contrib/framework/python/framework/checkpoint_utils_test.py index 4f591367fd..77a424145a 100644 --- a/tensorflow/contrib/framework/python/framework/checkpoint_utils_test.py +++ b/tensorflow/contrib/framework/python/framework/checkpoint_utils_test.py @@ -82,7 +82,7 @@ class CheckpointsTest(test.TestCase): def testNoTensor(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: _, _, _, _ = _create_checkpoints(session, checkpoint_dir) with self.assertRaises(errors_impl.OpError): self.assertAllEqual( @@ -90,7 +90,7 @@ class CheckpointsTest(test.TestCase): def testGetTensor(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: v1, v2, v3, v4 = _create_checkpoints(session, checkpoint_dir) self.assertAllEqual( checkpoint_utils.load_variable(checkpoint_dir, "var1"), v1) @@ -103,7 +103,7 @@ class CheckpointsTest(test.TestCase): def testGetAllVariables(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: _create_checkpoints(session, checkpoint_dir) self.assertEqual( checkpoint_utils.list_variables(checkpoint_dir), @@ -112,7 +112,7 @@ class CheckpointsTest(test.TestCase): def testInitFromCheckpoint(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: v1, v2, v3, v4 = _create_checkpoints(session, checkpoint_dir) # New graph and session. @@ -146,7 +146,7 @@ class CheckpointsTest(test.TestCase): def testInitWithScopeDoesNotCaptureSuffixes(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: _, _, _, v4 = _create_checkpoints(session, checkpoint_dir) with ops.Graph().as_default() as g: @@ -165,7 +165,7 @@ class CheckpointsTest(test.TestCase): def testInitFromRootCheckpoint(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: v1, v2, v3, v4 = _create_checkpoints(session, checkpoint_dir) # New graph and session. @@ -189,7 +189,7 @@ class CheckpointsTest(test.TestCase): def testInitToRootCheckpoint(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: v1, v2, v3, v4 = _create_checkpoints(session, checkpoint_dir) # New graph and session. @@ -212,7 +212,7 @@ class CheckpointsTest(test.TestCase): def testInitFromPartitionVar(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: v1 = _create_partition_checkpoints(session, checkpoint_dir) # New graph and session. @@ -266,7 +266,7 @@ class CheckpointsTest(test.TestCase): def testInitFromCheckpointMissing(self): checkpoint_dir = self.get_temp_dir() - with self.test_session() as session: + with self.cached_session() as session: _, _, _, _ = _create_checkpoints(session, checkpoint_dir) # New graph and session. diff --git a/tensorflow/contrib/framework/python/framework/tensor_util_test.py b/tensorflow/contrib/framework/python/framework/tensor_util_test.py index 2479fe5b8d..b1820c10c8 100644 --- a/tensorflow/contrib/framework/python/framework/tensor_util_test.py +++ b/tensorflow/contrib/framework/python/framework/tensor_util_test.py @@ -39,7 +39,7 @@ from tensorflow.python.platform import test class LocalVariabletest(test.TestCase): def test_local_variable(self): - with self.test_session() as sess: + with self.cached_session() as sess: self.assertEquals([], variables_lib.local_variables()) value0 = 42 variables_lib2.local_variable(value0) @@ -55,7 +55,7 @@ class LocalVariabletest(test.TestCase): class ReduceSumNTest(test.TestCase): def test_reduce_sum_n(self): - with self.test_session(): + with self.cached_session(): a = constant_op.constant(1) b = constant_op.constant([2]) c = constant_op.constant([[3, 4], [5, 6]]) @@ -119,13 +119,13 @@ class WithShapeTest(test.TestCase): })) def test_with_shape_invalid_expected_shape(self): - with self.test_session(): + with self.cached_session(): self.assertRaisesRegexp(ValueError, "Invalid rank", tensor_util.with_shape, [[1], [2]], constant_op.constant(1.0)) def test_with_shape_invalid_type(self): - with self.test_session(): + with self.cached_session(): self.assertRaisesRegexp(ValueError, "Invalid dtype", tensor_util.with_shape, [1.1], constant_op.constant([1.0])) @@ -138,7 +138,7 @@ class WithShapeTest(test.TestCase): constant_op.constant(1.0)) def test_with_shape_0(self): - with self.test_session(): + with self.cached_session(): value = 42 shape = [0] unexpected_shapes = [[1], [2], [1, 1]] @@ -150,7 +150,7 @@ class WithShapeTest(test.TestCase): unexpected_shapes) def test_with_shape_1(self): - with self.test_session(): + with self.cached_session(): value = [42] shape = [1] unexpected_shapes = [[0], [2], [1, 1]] @@ -162,7 +162,7 @@ class WithShapeTest(test.TestCase): unexpected_shapes) def test_with_shape_2(self): - with self.test_session(): + with self.cached_session(): value = [42, 43] shape = [2] unexpected_shapes = [[0], [1], [2, 1]] @@ -174,7 +174,7 @@ class WithShapeTest(test.TestCase): unexpected_shapes) def test_with_shape_2x2(self): - with self.test_session(): + with self.cached_session(): value = [[42, 43], [44, 45]] shape = [2, 2] unexpected_shapes = [[0], [1], [2, 1]] @@ -196,7 +196,7 @@ class WithShapeTest(test.TestCase): np.testing.assert_array_equal(value, tensor_with_shape.eval()) def test_with_shape_none(self): - with self.test_session(): + with self.cached_session(): tensor_no_shape = array_ops.placeholder(dtypes.float32) compatible_shape = [2, 2] @@ -220,7 +220,7 @@ class WithShapeTest(test.TestCase): @test_util.enable_c_shapes def test_with_shape_partial(self): - with self.test_session(): + with self.cached_session(): tensor_partial_shape = array_ops.placeholder(dtypes.float32) tensor_partial_shape.set_shape([None, 2]) |