Salome HOME
Fix tests using unittest (failed cases were not reported by ctest).
[modules/shaper.git] / src / ModelHighAPI / Test / TestRefAttr.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
7 ##
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 ## Lesser General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 import unittest
22
23 import ModelAPI
24 import ModelHighAPI
25 from salome.shaper import model
26
27 class FeaturesFixture(unittest.TestCase):
28
29     def setUp(self):
30         model.begin()
31         # Create part
32         partset = model.moduleDocument()
33         self.part = model.addPart(partset).document()
34         model.do()
35         self.feature = model.addPoint(self.part, 0, 0, 0)
36
37     def tearDown(self):
38         model.end()
39         model.reset()
40
41
42 class RefAttrTestCase(FeaturesFixture):
43
44     def test_create_default(self):
45         ModelHighAPI.ModelHighAPI_RefAttr()
46
47     def test_create_from_attribute(self):
48         print(self.feature.x())
49         ModelHighAPI.ModelHighAPI_RefAttr(self.feature.x())
50
51     def test_create_from_object(self):
52         ModelHighAPI.ModelHighAPI_RefAttr(self.feature.feature())
53
54     def test_create_from_None(self):
55         ModelHighAPI.ModelHighAPI_RefAttr(None)
56
57
58 if __name__ == "__main__":
59     test_program = unittest.main(exit=False)
60     assert test_program.result.wasSuccessful(), "Test failed"