Skip to content

Commit a90f837

Browse files
committed
Add version test
1 parent da433f7 commit a90f837

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import unittest
16+
import re
17+
18+
import paddle.version as fluid_version
19+
20+
class VersionTest(unittest.TestCase):
21+
def setUp(self):
22+
self._major_regex = "[0-9]+"
23+
self._minor_regex = "[0-9]+"
24+
self._patch_regex = "[0-9]+(\\.(a|b|rc)\\.[0-9]+)?"
25+
self._rc_regex = "[0-9]+"
26+
self._version_regex = "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?"
27+
self._commit_regex = "[0-9a-f]{5,49}"
28+
29+
def test_check_output(self):
30+
# check commit format
31+
self.assertTrue(re.match(self._commit_regex, fluid_version.commit))
32+
self.assertTrue(isinstance(fluid_version.istaged, bool))
33+
34+
# check version format
35+
if fluid_version.istaged:
36+
self.assertEqual(fluid_version.major, 0)
37+
self.assertEqual(fluid_version.minor, 0)
38+
self.assertEqual(fluid_version.patch, "0")
39+
self.assertEqual(fluid_version.rc, 0)
40+
self.assertEqual(fluid_version.full_version, "0.0.0")
41+
else:
42+
self.assertTrue(re.match(self._major_regex, fluid_version.major))
43+
self.assertTrue(re.match(self._minor_regex, fluid_version.minor))
44+
self.assertTrue(re.match(self._patch_regex, fluid_version.patch))
45+
self.assertTrue(re.match(self._rc_regex, fluid_version.rc))
46+
self.assertTrue(re.match(self._version_regex, fluid_version.full_version))
47+
48+

0 commit comments

Comments
 (0)