import clr
import types
import unittest
import Python.Test as Test
import System
import six
from Python.Test import ClassTest
from System.Collections import Hashtable
if six.PY3:
DictProxyType = type(object.__dict__)
else:
DictProxyType = types.DictProxyType
class ClassTests(unittest.TestCase):
"""Test CLR class support."""
def testBasicReferenceType(self):
"""Test usage of CLR defined reference types."""
String = System.String
self.assertEquals(String.Empty, "")
def testBasicValueType(self):
"""Test usage of CLR defined value types."""
Int32 = System.Int32
self.assertEquals(Int32.MaxValue, 2147483647)
def testClassStandardAttrs(self):
"""Test standard class attributes."""
self.assertTrue(ClassTest.__name__ == 'ClassTest')
self.assertTrue(ClassTest.__module__ == 'Python.Test')
self.assertTrue(type(ClassTest.__dict__) == DictProxyType)
self.assertTrue(len(ClassTest.__doc__) > 0)
def testClassDocstrings(self):
"""Test standard class docstring generation"""
value = 'Void .ctor()'
self.assertTrue(ClassTest.__doc__ == value)
def testClassDefaultStr(self):
"""Test the default __str__ implementation for managed objects."""
s = System.String("this is a test")
self.assertTrue(str(s) == "this is a test")
def testClassDefaultRepr(self):
"""Test the default __repr__ implementation for managed objects."""
s = System.String("this is a test")
self.assertTrue(repr(s).startswith("