[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/kingctan/pythonnet/develop/src/tests/test_class.py [Back]  [Original]

# ===========================================================================
# 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.
# ===========================================================================
from System.Collections import Hashtable
from Python.Test import ClassTest
import sys, os, string, unittest, types
import Python.Test as Test
import System


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__) == types.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("

Web Proxy Viewer  |  New URL  |  Original Page