From 101240d2c1e7995f4ad6804383e45a8be56f9745 Mon Sep 17 00:00:00 2001 From: Zhang Ting <709968123@qq.com> Date: Mon, 2 Dec 2019 16:33:04 +0800 Subject: [PATCH] fix PythonAPI test in Op unittest, test=develop (#21462) There are PythonAPI tests in Op's unittest which don't need to inherit OpTest class. --- python/paddle/fluid/tests/unittests/test_batch_norm_op.py | 2 +- python/paddle/fluid/tests/unittests/test_expand_as_op.py | 2 +- python/paddle/fluid/tests/unittests/test_gather_nd_op.py | 4 ++-- .../fluid/tests/unittests/test_locality_aware_nms_op.py | 2 +- python/paddle/fluid/tests/unittests/test_lrn_op.py | 2 +- python/paddle/fluid/tests/unittests/test_nearest_interp_op.py | 4 ++-- python/paddle/fluid/tests/unittests/test_print_op.py | 2 +- python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py | 2 +- python/paddle/fluid/tests/unittests/test_zeros_op.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py index 5e3c41441db..851dfe39e48 100644 --- a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py @@ -575,7 +575,7 @@ class TestBatchNormOpFreezeStatsAndScaleBiasTraining( self.fetch_list = ['y', 'mean', 'variance', 'x@GRAD'] -class TestBatchNormOpError(OpTest): +class TestBatchNormOpError(unittest.TestCase): def test_errors(self): with program_guard(Program(), Program()): # the input of batch_norm must be Variable. diff --git a/python/paddle/fluid/tests/unittests/test_expand_as_op.py b/python/paddle/fluid/tests/unittests/test_expand_as_op.py index 836e49c54e2..c5d09ac3cd1 100755 --- a/python/paddle/fluid/tests/unittests/test_expand_as_op.py +++ b/python/paddle/fluid/tests/unittests/test_expand_as_op.py @@ -103,7 +103,7 @@ class TestExpandAsOpRank4(OpTest): # Test python API -class TestExpandAPI(OpTest): +class TestExpandAPI(unittest.TestCase): def test_api(self): input1 = np.random.random([12, 14]).astype("float32") input2 = np.random.random([48, 14]).astype("float32") diff --git a/python/paddle/fluid/tests/unittests/test_gather_nd_op.py b/python/paddle/fluid/tests/unittests/test_gather_nd_op.py index 357b2dc0607..724b8040354 100644 --- a/python/paddle/fluid/tests/unittests/test_gather_nd_op.py +++ b/python/paddle/fluid/tests/unittests/test_gather_nd_op.py @@ -128,7 +128,7 @@ class TestGatherNdOpWithHighRankDiff(OpTest): #Test Python API -class TestGatherNdOpAPI(OpTest): +class TestGatherNdOpAPI(unittest.TestCase): def test_case1(self): x1 = fluid.layers.data( name='x1', shape=[30, 40, 50, 60], dtype='float32') @@ -147,7 +147,7 @@ class TestGatherNdOpAPI(OpTest): #Test Raise Index Error -class TestGatherNdOpRaise(OpTest): +class TestGatherNdOpRaise(unittest.TestCase): def test_check_raise(self): def check_raise_is_test(): try: diff --git a/python/paddle/fluid/tests/unittests/test_locality_aware_nms_op.py b/python/paddle/fluid/tests/unittests/test_locality_aware_nms_op.py index bed185551b7..e4845c90a60 100644 --- a/python/paddle/fluid/tests/unittests/test_locality_aware_nms_op.py +++ b/python/paddle/fluid/tests/unittests/test_locality_aware_nms_op.py @@ -307,7 +307,7 @@ class TestLocalAwareNMSOp4Points(OpTest): self.check_output() -class TestLocalityAwareNMSAPI(OpTest): +class TestLocalityAwareNMSAPI(unittest.TestCase): def test_api(self): boxes = fluid.data(name='bboxes', shape=[None, 81, 8], dtype='float32') scores = fluid.data(name='scores', shape=[None, 1, 81], dtype='float32') diff --git a/python/paddle/fluid/tests/unittests/test_lrn_op.py b/python/paddle/fluid/tests/unittests/test_lrn_op.py index 7ec329d9f6c..bf6b555c466 100644 --- a/python/paddle/fluid/tests/unittests/test_lrn_op.py +++ b/python/paddle/fluid/tests/unittests/test_lrn_op.py @@ -106,7 +106,7 @@ class TestLRNOpAttrDataFormat(TestLRNOp): self.data_format = 'NHWC' -class TestLRNAPI(OpTest): +class TestLRNAPI(unittest.TestCase): def test_case(self): data1 = fluid.data(name='data1', shape=[2, 4, 5, 5], dtype='float32') data2 = fluid.data(name='data2', shape=[2, 5, 5, 4], dtype='float32') diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index a8d16677e22..bb90279ea93 100755 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -423,7 +423,7 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor): self.scale_by_1Dtensor = True -class TestNearestAPI(OpTest): +class TestNearestAPI(unittest.TestCase): def test_case(self): x = fluid.data(name="x", shape=[2, 3, 6, 6], dtype="float32") y = fluid.data(name="y", shape=[2, 6, 6, 3], dtype="float32") @@ -474,7 +474,7 @@ class TestNearestAPI(OpTest): self.assertTrue(np.allclose(results[i + 1], expect_res)) -class TestNearestInterpException(OpTest): +class TestNearestInterpException(unittest.TestCase): def test_exception(self): input = fluid.data(name="input", shape=[1, 3, 6, 6], dtype="float32") diff --git a/python/paddle/fluid/tests/unittests/test_print_op.py b/python/paddle/fluid/tests/unittests/test_print_op.py index 49b55e376b4..21bf3f0b287 100644 --- a/python/paddle/fluid/tests/unittests/test_print_op.py +++ b/python/paddle/fluid/tests/unittests/test_print_op.py @@ -82,7 +82,7 @@ class TestPrintOpCPU(unittest.TestCase): return_numpy=False) -class TestPrintOpError(OpTest): +class TestPrintOpError(unittest.TestCase): def test_errors(self): with program_guard(Program(), Program()): # The input type of Print_op must be Variable. diff --git a/python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py b/python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py index 0e553287b56..51fb7302960 100644 --- a/python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py +++ b/python/paddle/fluid/tests/unittests/test_unsqueeze2_op.py @@ -203,7 +203,7 @@ class TestUnsqueezeOp4_AxesTensor(TestUnsqueezeOp_AxesTensor): # test api -class TestUnsqueezeAPI(OpTest): +class TestUnsqueezeAPI(unittest.TestCase): def test_api(self): input = np.random.random([3, 2, 5]).astype("float32") x = fluid.data(name='x', shape=[3, 2, 5], dtype="float32") diff --git a/python/paddle/fluid/tests/unittests/test_zeros_op.py b/python/paddle/fluid/tests/unittests/test_zeros_op.py index 1be2f4d0479..6ce39cd6376 100644 --- a/python/paddle/fluid/tests/unittests/test_zeros_op.py +++ b/python/paddle/fluid/tests/unittests/test_zeros_op.py @@ -24,7 +24,7 @@ import paddle.fluid as fluid from paddle.fluid import compiler, Program, program_guard -class TestZerosOpError(OpTest): +class TestZerosOpError(unittest.TestCase): def test_errors(self): with program_guard(Program(), Program()): # The input dtype of zeros_op must be bool, float16, float32, float64, int32, int64. -- GitLab