From 8a162085d1e448b9b376656b170c7023477eccc8 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 13 Oct 2016 14:38:44 -0800 Subject: [PATCH] Moves tests from contrib/learn/tests to a better place whenever possible. Change: 136095744 --- tensorflow/contrib/learn/BUILD | 42 ++++------ .../contrib/learn/python/learn/datasets/BUILD | 12 +++ .../{tests => datasets}/load_csv_test.py | 0 .../learn/{tests => estimators}/base_test.py | 0 .../{tests => estimators}/estimators_test.py | 0 .../{tests => estimators}/multioutput_test.py | 0 .../{tests => estimators}/nonlinear_test.py | 0 .../{tests => estimators}/regression_test.py | 0 .../{tests => estimators}/run_config_test.py | 0 .../{tests => estimators}/stability_test.py | 0 .../learn/{tests => }/experiment_test.py | 0 .../learn/{tests => }/graph_actions_test.py | 0 .../learn/{tests => }/grid_search_test.py | 0 .../{tests => learn_io}/data_feeder_test.py | 0 .../learn/{tests => learn_io}/io_test.py | 0 .../learn/{tests => }/learn_runner_test.py | 0 .../learn/{tests => }/metric_spec_test.py | 0 .../python/learn/{tests => }/monitors_test.py | 0 .../learn/tests/summary_writer_cache_test.py | 78 ------------------- 19 files changed, 27 insertions(+), 105 deletions(-) rename tensorflow/contrib/learn/python/learn/{tests => datasets}/load_csv_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/base_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/estimators_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/multioutput_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/nonlinear_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/regression_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/run_config_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => estimators}/stability_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/experiment_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/graph_actions_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/grid_search_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => learn_io}/data_feeder_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => learn_io}/io_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/learn_runner_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/metric_spec_test.py (100%) rename tensorflow/contrib/learn/python/learn/{tests => }/monitors_test.py (100%) delete mode 100644 tensorflow/contrib/learn/python/learn/tests/summary_writer_cache_test.py diff --git a/tensorflow/contrib/learn/BUILD b/tensorflow/contrib/learn/BUILD index b25605e2d28..b6d83884f4d 100644 --- a/tensorflow/contrib/learn/BUILD +++ b/tensorflow/contrib/learn/BUILD @@ -27,19 +27,7 @@ py_library( py_test( name = "base_test", size = "medium", - srcs = ["python/learn/tests/base_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":learn", - "//tensorflow:tensorflow_py", - "//tensorflow/python:framework_test_lib", - ], -) - -py_test( - name = "load_csv_test", - size = "small", - srcs = ["python/learn/tests/load_csv_test.py"], + srcs = ["python/learn/estimators/base_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -51,7 +39,7 @@ py_test( py_test( name = "data_feeder_test", size = "small", - srcs = ["python/learn/tests/data_feeder_test.py"], + srcs = ["python/learn/learn_io/data_feeder_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -274,7 +262,7 @@ py_test( py_test( name = "estimators_test", size = "small", - srcs = ["python/learn/tests/estimators_test.py"], + srcs = ["python/learn/estimators/estimators_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -286,7 +274,7 @@ py_test( py_test( name = "metric_spec_test", size = "small", - srcs = ["python/learn/tests/metric_spec_test.py"], + srcs = ["python/learn/metric_spec_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -298,7 +286,7 @@ py_test( py_test( name = "experiment_test", size = "small", - srcs = ["python/learn/tests/experiment_test.py"], + srcs = ["python/learn/experiment_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -310,7 +298,7 @@ py_test( py_test( name = "graph_actions_test", size = "small", - srcs = ["python/learn/tests/graph_actions_test.py"], + srcs = ["python/learn/graph_actions_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -322,7 +310,7 @@ py_test( py_test( name = "learn_runner_test", size = "small", - srcs = ["python/learn/tests/learn_runner_test.py"], + srcs = ["python/learn/learn_runner_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -334,7 +322,7 @@ py_test( py_test( name = "monitors_test", size = "small", - srcs = ["python/learn/tests/monitors_test.py"], + srcs = ["python/learn/monitors_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -347,7 +335,7 @@ py_test( name = "run_config_test", size = "small", srcs = [ - "python/learn/tests/run_config_test.py", + "python/learn/estimators/run_config_test.py", ], srcs_version = "PY2AND3", deps = [ @@ -522,7 +510,7 @@ py_test( py_test( name = "grid_search_test", size = "small", - srcs = ["python/learn/tests/grid_search_test.py"], + srcs = ["python/learn/grid_search_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -534,7 +522,7 @@ py_test( py_test( name = "io_test", size = "small", - srcs = ["python/learn/tests/io_test.py"], + srcs = ["python/learn/learn_io/io_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -546,7 +534,7 @@ py_test( py_test( name = "multioutput_test", size = "small", - srcs = ["python/learn/tests/multioutput_test.py"], + srcs = ["python/learn/estimators/multioutput_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -558,7 +546,7 @@ py_test( py_test( name = "nonlinear_test", size = "medium", - srcs = ["python/learn/tests/nonlinear_test.py"], + srcs = ["python/learn/estimators/nonlinear_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -570,7 +558,7 @@ py_test( py_test( name = "regression_test", size = "small", - srcs = ["python/learn/tests/regression_test.py"], + srcs = ["python/learn/estimators/regression_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", @@ -671,7 +659,7 @@ py_test( py_test( name = "stability_test", size = "small", - srcs = ["python/learn/tests/stability_test.py"], + srcs = ["python/learn/estimators/stability_test.py"], srcs_version = "PY2AND3", deps = [ ":learn", diff --git a/tensorflow/contrib/learn/python/learn/datasets/BUILD b/tensorflow/contrib/learn/python/learn/datasets/BUILD index 43a4aa0d0d3..ec1fa815f84 100644 --- a/tensorflow/contrib/learn/python/learn/datasets/BUILD +++ b/tensorflow/contrib/learn/python/learn/datasets/BUILD @@ -43,3 +43,15 @@ filegroup( ), visibility = ["//tensorflow:__subpackages__"], ) + +py_test( + name = "load_csv_test", + size = "small", + srcs = ["load_csv_test.py"], + srcs_version = "PY2AND3", + deps = [ + "//tensorflow:tensorflow_py", + "//tensorflow/contrib/learn", + "//tensorflow/python:framework_test_lib", + ], +) diff --git a/tensorflow/contrib/learn/python/learn/tests/load_csv_test.py b/tensorflow/contrib/learn/python/learn/datasets/load_csv_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/load_csv_test.py rename to tensorflow/contrib/learn/python/learn/datasets/load_csv_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/base_test.py b/tensorflow/contrib/learn/python/learn/estimators/base_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/base_test.py rename to tensorflow/contrib/learn/python/learn/estimators/base_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/estimators_test.py b/tensorflow/contrib/learn/python/learn/estimators/estimators_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/estimators_test.py rename to tensorflow/contrib/learn/python/learn/estimators/estimators_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/multioutput_test.py b/tensorflow/contrib/learn/python/learn/estimators/multioutput_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/multioutput_test.py rename to tensorflow/contrib/learn/python/learn/estimators/multioutput_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/nonlinear_test.py b/tensorflow/contrib/learn/python/learn/estimators/nonlinear_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/nonlinear_test.py rename to tensorflow/contrib/learn/python/learn/estimators/nonlinear_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/regression_test.py b/tensorflow/contrib/learn/python/learn/estimators/regression_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/regression_test.py rename to tensorflow/contrib/learn/python/learn/estimators/regression_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/run_config_test.py b/tensorflow/contrib/learn/python/learn/estimators/run_config_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/run_config_test.py rename to tensorflow/contrib/learn/python/learn/estimators/run_config_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/stability_test.py b/tensorflow/contrib/learn/python/learn/estimators/stability_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/stability_test.py rename to tensorflow/contrib/learn/python/learn/estimators/stability_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/experiment_test.py b/tensorflow/contrib/learn/python/learn/experiment_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/experiment_test.py rename to tensorflow/contrib/learn/python/learn/experiment_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/graph_actions_test.py b/tensorflow/contrib/learn/python/learn/graph_actions_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/graph_actions_test.py rename to tensorflow/contrib/learn/python/learn/graph_actions_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/grid_search_test.py b/tensorflow/contrib/learn/python/learn/grid_search_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/grid_search_test.py rename to tensorflow/contrib/learn/python/learn/grid_search_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/data_feeder_test.py b/tensorflow/contrib/learn/python/learn/learn_io/data_feeder_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/data_feeder_test.py rename to tensorflow/contrib/learn/python/learn/learn_io/data_feeder_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/io_test.py b/tensorflow/contrib/learn/python/learn/learn_io/io_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/io_test.py rename to tensorflow/contrib/learn/python/learn/learn_io/io_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/learn_runner_test.py b/tensorflow/contrib/learn/python/learn/learn_runner_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/learn_runner_test.py rename to tensorflow/contrib/learn/python/learn/learn_runner_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/metric_spec_test.py b/tensorflow/contrib/learn/python/learn/metric_spec_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/metric_spec_test.py rename to tensorflow/contrib/learn/python/learn/metric_spec_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/monitors_test.py b/tensorflow/contrib/learn/python/learn/monitors_test.py similarity index 100% rename from tensorflow/contrib/learn/python/learn/tests/monitors_test.py rename to tensorflow/contrib/learn/python/learn/monitors_test.py diff --git a/tensorflow/contrib/learn/python/learn/tests/summary_writer_cache_test.py b/tensorflow/contrib/learn/python/learn/tests/summary_writer_cache_test.py deleted file mode 100644 index 2df47a75ba5..00000000000 --- a/tensorflow/contrib/learn/python/learn/tests/summary_writer_cache_test.py +++ /dev/null @@ -1,78 +0,0 @@ -# pylint: disable=g-bad-file-header -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Runner.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import os - -import tensorflow as tf - -from tensorflow.contrib.learn.python.learn import summary_writer_cache - - -class SummaryWriterCacheTest(tf.test.TestCase): - """SummaryWriterCache tests.""" - - def _test_dir(self, test_name): - """Create an empty dir to use for tests. - - Args: - test_name: Name of the test. - - Returns: - Absolute path to the test directory. - """ - test_dir = os.path.join(self.get_temp_dir(), test_name) - if os.path.isdir(test_dir): - for f in glob.glob('%s/*' % test_dir): - os.remove(f) - else: - os.makedirs(test_dir) - return test_dir - - def test_cache(self): - with tf.Graph().as_default(): - dir1 = self._test_dir('test_cache_1') - dir2 = self._test_dir('test_cache_2') - sw1 = summary_writer_cache.SummaryWriterCache.get(dir1) - sw2 = summary_writer_cache.SummaryWriterCache.get(dir2) - sw3 = summary_writer_cache.SummaryWriterCache.get(dir1) - self.assertEqual(sw1, sw3) - self.assertFalse(sw1 == sw2) - sw1.close() - sw2.close() - events1 = glob.glob(os.path.join(dir1, 'event*')) - self.assertTrue(events1) - events2 = glob.glob(os.path.join(dir2, 'event*')) - self.assertTrue(events2) - events3 = glob.glob(os.path.join('nowriter', 'event*')) - self.assertFalse(events3) - - def test_clear(self): - with tf.Graph().as_default(): - dir1 = self._test_dir('test_clear') - sw1 = summary_writer_cache.SummaryWriterCache.get(dir1) - summary_writer_cache.SummaryWriterCache.clear() - sw2 = summary_writer_cache.SummaryWriterCache.get(dir1) - self.assertFalse(sw1 == sw2) - - -if __name__ == '__main__': - tf.test.main()