aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/util
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-10 14:36:26 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-10 14:49:41 -0700
commit890e16594a005fe703a5556530b0dc3e6527fa47 (patch)
tree99140efb13f392ae13a58f08c08754c61bf66f13 /tensorflow/python/util
parent132babebf5b1026cb33cad7c4eb7e03810c2acdf (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: 212336321
Diffstat (limited to 'tensorflow/python/util')
-rw-r--r--tensorflow/python/util/nest_test.py2
-rw-r--r--tensorflow/python/util/tf_should_use_test.py5
2 files changed, 4 insertions, 3 deletions
diff --git a/tensorflow/python/util/nest_test.py b/tensorflow/python/util/nest_test.py
index 2369eb610e..ef503137d1 100644
--- a/tensorflow/python/util/nest_test.py
+++ b/tensorflow/python/util/nest_test.py
@@ -461,7 +461,7 @@ class NestTest(parameterized.TestCase, test.TestCase):
inp_b: (np.random.randn(3, 4), np.random.randn(3, 7))
}
- with self.test_session() as sess:
+ with self.cached_session() as sess:
output_np = sess.run(output, feed_dict=feed_dict)
self.assertAllClose(output_np[0],
feed_dict[inp_a][0] + feed_dict[inp_b][0])
diff --git a/tensorflow/python/util/tf_should_use_test.py b/tensorflow/python/util/tf_should_use_test.py
index 16fa1f547d..fedbe1dff6 100644
--- a/tensorflow/python/util/tf_should_use_test.py
+++ b/tensorflow/python/util/tf_should_use_test.py
@@ -106,7 +106,7 @@ class TfShouldUseTest(test.TestCase):
def return_const(value):
return constant_op.constant(value, name='blah3')
with reroute_error() as (error, _):
- with self.test_session():
+ with self.cached_session():
return_const(0.0)
# Creating another op and executing it does not mark the
# unused op as being "used".
@@ -124,7 +124,8 @@ class TfShouldUseTest(test.TestCase):
@tf_should_use.should_use_result
def return_const(value):
return constant_op.constant(value, name='blah3')
- with self.test_session():
+
+ with self.cached_session():
return_const(0.0).mark_used()
if __name__ == '__main__':