[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/generalloki/pythonnet/python-3.13/tests/test_class.py [Back]  [Original]

# -*- coding: utf-8 -*-
# TODO: Add tests for ClassicClass, NewStyleClass?

"""Test CLR class support."""

import clr
import Python.Test as Test
import System
import pytest

from .utils import DictProxyType


def test_basic_reference_type():
    """Test usage of CLR defined reference types."""
    assert System.String.Empty == ""

def test_basic_value_type():
    """Test usage of CLR defined value types."""
    assert System.Int32.MaxValue == 2147483647


def test_class_standard_attrs():
    """Test standard class attributes."""
    from Python.Test import ClassTest

    assert ClassTest.__name__ == 'ClassTest'
    assert ClassTest.__module__ == 'Python.Test'
    assert isinstance(ClassTest.__dict__, DictProxyType)
    assert len(ClassTest.__doc__) > 0

def test_class_docstrings():
    """Test standard class docstring generation"""
    from Python.Test import ClassTest

    value = 'Void .ctor()'
    assert ClassTest.__doc__ == value


def test_class_default_str():
    """Test the default __str__ implementation for managed objects."""
    s = System.String("this is a test")
    assert str(s) == "this is a test"


def test_class_default_repr():
    """Test the default __repr__ implementation for managed objects."""
    s = System.String("this is a test")
    assert repr(s).startswith("

Web Proxy Viewer  |  New URL  |  Original Page