From 431e8dbd83406acae304d31d31eec9b88f6ac899 Mon Sep 17 00:00:00 2001 From: Kim Date: Tue, 28 Mar 2023 11:12:27 +0800 Subject: [PATCH] [Test Mv]mv dataset test (#52148) * mv python/paddle/dataset/tests/ test/dataset/ * use path to get file path * add dataset * remove cmake entry * add all ops * solve conflicts --- python/CMakeLists.txt | 1 - python/paddle/dataset/tests/CMakeLists.txt | 1 - test/CMakeLists.txt | 2 +- test/dataset/CMakeLists.txt | 9 +++++++++ .../paddle/dataset/tests => test/dataset}/cat.jpg | Bin .../dataset/tests => test/dataset}/cifar_test.py | 0 .../dataset/tests => test/dataset}/flowers_test.py | 0 .../dataset/tests => test/dataset}/imdb_test.py | 0 .../dataset/tests => test/dataset}/imikolov_test.py | 0 .../dataset/tests => test/dataset}/mnist_test.py | 0 .../dataset/tests => test/dataset}/test_image.py | 7 ++++--- .../dataset/tests => test/dataset}/voc2012_test.py | 0 .../dataset/tests => test/dataset}/wmt16_test.py | 0 13 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 python/paddle/dataset/tests/CMakeLists.txt create mode 100644 test/dataset/CMakeLists.txt rename {python/paddle/dataset/tests => test/dataset}/cat.jpg (100%) rename {python/paddle/dataset/tests => test/dataset}/cifar_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/flowers_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/imdb_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/imikolov_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/mnist_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/test_image.py (93%) rename {python/paddle/dataset/tests => test/dataset}/voc2012_test.py (100%) rename {python/paddle/dataset/tests => test/dataset}/wmt16_test.py (100%) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 241f1fb0300..05e41642a2c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -149,7 +149,6 @@ add_custom_target(paddle_python ALL set(PADDLE_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/) if(WITH_TESTING) - add_subdirectory(paddle/dataset/tests) add_subdirectory(paddle/fluid/tests) add_subdirectory(paddle/static/quantization/tests) endif() diff --git a/python/paddle/dataset/tests/CMakeLists.txt b/python/paddle/dataset/tests/CMakeLists.txt deleted file mode 100644 index 485c38a13b5..00000000000 --- a/python/paddle/dataset/tests/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -py_test(test_image SRCS test_image.py) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 37623567d22..60d05fbdf57 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,7 +17,7 @@ if(WITH_TESTING) add_subdirectory(custom_kernel) add_subdirectory(custom_op) # add_subdirectory(custom_runtime) - # add_subdirectory(dataset) + add_subdirectory(dataset) # add_subdirectory(distributed_passes) # add_subdirectory(distribution) # add_subdirectory(dygraph_to_static) diff --git a/test/dataset/CMakeLists.txt b/test/dataset/CMakeLists.txt new file mode 100644 index 00000000000..ec4cf735704 --- /dev/null +++ b/test/dataset/CMakeLists.txt @@ -0,0 +1,9 @@ +file( + GLOB TEST_OPS + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "test_*.py") +string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") + +foreach(src ${TEST_OPS}) + py_test(${src} SRCS ${src}.py) +endforeach() diff --git a/python/paddle/dataset/tests/cat.jpg b/test/dataset/cat.jpg similarity index 100% rename from python/paddle/dataset/tests/cat.jpg rename to test/dataset/cat.jpg diff --git a/python/paddle/dataset/tests/cifar_test.py b/test/dataset/cifar_test.py similarity index 100% rename from python/paddle/dataset/tests/cifar_test.py rename to test/dataset/cifar_test.py diff --git a/python/paddle/dataset/tests/flowers_test.py b/test/dataset/flowers_test.py similarity index 100% rename from python/paddle/dataset/tests/flowers_test.py rename to test/dataset/flowers_test.py diff --git a/python/paddle/dataset/tests/imdb_test.py b/test/dataset/imdb_test.py similarity index 100% rename from python/paddle/dataset/tests/imdb_test.py rename to test/dataset/imdb_test.py diff --git a/python/paddle/dataset/tests/imikolov_test.py b/test/dataset/imikolov_test.py similarity index 100% rename from python/paddle/dataset/tests/imikolov_test.py rename to test/dataset/imikolov_test.py diff --git a/python/paddle/dataset/tests/mnist_test.py b/test/dataset/mnist_test.py similarity index 100% rename from python/paddle/dataset/tests/mnist_test.py rename to test/dataset/mnist_test.py diff --git a/python/paddle/dataset/tests/test_image.py b/test/dataset/test_image.py similarity index 93% rename from python/paddle/dataset/tests/test_image.py rename to test/dataset/test_image.py index 8656ef2669b..54858da9da1 100644 --- a/python/paddle/dataset/tests/test_image.py +++ b/test/dataset/test_image.py @@ -17,8 +17,7 @@ Fliename: Description: This scipt test image resize,flip and chw. """ - -import sys +import os import unittest import numpy as np @@ -35,7 +34,9 @@ class Image(unittest.TestCase): def test_resize_flip_chw(self): """resize""" - imgdir = sys.argv[0].replace('test_image.py', 'cat.jpg') + imgdir = os.path.join( + os.path.dirname(os.path.abspath(__file__)), 'cat.jpg' + ) images = image.load_image(imgdir) images = image.resize_short(images, 256) self.assertEqual(256, min(images.shape[:2])) diff --git a/python/paddle/dataset/tests/voc2012_test.py b/test/dataset/voc2012_test.py similarity index 100% rename from python/paddle/dataset/tests/voc2012_test.py rename to test/dataset/voc2012_test.py diff --git a/python/paddle/dataset/tests/wmt16_test.py b/test/dataset/wmt16_test.py similarity index 100% rename from python/paddle/dataset/tests/wmt16_test.py rename to test/dataset/wmt16_test.py -- GitLab