forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_constructors.py
More file actions
executable file
·68 lines (47 loc) · 2 KB
/
test_constructors.py
File metadata and controls
executable file
·68 lines (47 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ===========================================================================
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# ===========================================================================
import sys, os, string, unittest, types
import Python.Test as Test
import System
class ConstructorTests(unittest.TestCase):
"""Test CLR class constructor support."""
def testEnumConstructor(self):
"""Test enum constructor args"""
from Test import EnumConstructorTest
ob = EnumConstructorTest(TypeCode.Int32)
self.failUnless(ob.value == TypeCode.Int32)
def testFlagsConstructor(self):
"""Test flags constructor args"""
from Test import FlagsConstructorTest
from System.IO import FileAccess
flags = FileAccess.Read | FileAccess.Write
ob = FlagsConstructorTest(flags)
self.failUnless(ob.value == flags)
def testStructConstructor(self):
"""Test struct constructor args"""
from Test import StructConstructorTest
guid = Guid.NewGuid()
ob = StructConstructorTest(guid)
self.failUnless(ob.value == guid)
def testSubclassConstructor(self):
"""Test subclass constructor args"""
from Test import SubclassConstructorTest
from System.Windows.Forms import Form, Control
class sub(Form):
pass
form = sub()
ob = SubclassConstructorTest(form)
self.failUnless(isinstance(ob.value, Control))
def test_suite():
return unittest.makeSuite(ConstructorTests)
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__':
testcase.setup()
main()