From 96e974a0342f0bac11332c7acc35ef956e0ccc3c Mon Sep 17 00:00:00 2001 From: Zhou Wei <1183042833@qq.com> Date: Thu, 29 Dec 2022 12:11:05 +0800 Subject: [PATCH] [cherry-pick]fix bug of UT test_version, test=document_fix (#49401) --- .../fluid/tests/unittests/test_version.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_version.py b/python/paddle/fluid/tests/unittests/test_version.py index d312888668..55b5228882 100644 --- a/python/paddle/fluid/tests/unittests/test_version.py +++ b/python/paddle/fluid/tests/unittests/test_version.py @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function - -import unittest import re +import unittest import paddle.version as fluid_version class VersionTest(unittest.TestCase): - def setUp(self): self._major_regex = "[0-9]+" self._minor_regex = "[0-9]+" @@ -37,15 +34,20 @@ class VersionTest(unittest.TestCase): # check version format if fluid_version.istaged: - self.assertEqual(fluid_version.major, 0) - self.assertEqual(fluid_version.minor, 0) - self.assertEqual(fluid_version.patch, "0") - self.assertEqual(fluid_version.rc, 0) - self.assertEqual(fluid_version.full_version, "0.0.0") - else: self.assertTrue(re.match(self._major_regex, fluid_version.major)) self.assertTrue(re.match(self._minor_regex, fluid_version.minor)) self.assertTrue(re.match(self._patch_regex, fluid_version.patch)) self.assertTrue(re.match(self._rc_regex, fluid_version.rc)) self.assertTrue( - re.match(self._version_regex, fluid_version.full_version)) + re.match(self._version_regex, fluid_version.full_version) + ) + else: + self.assertEqual(fluid_version.major, "0") + self.assertEqual(fluid_version.minor, "0") + self.assertEqual(fluid_version.patch, "0") + self.assertEqual(fluid_version.rc, "0") + self.assertEqual(fluid_version.full_version, "0.0.0") + + +if __name__ == '__main__': + unittest.main() -- GitLab