Beispiel #1
0
def test_from_cmdline_neg():
    '''
    '''
    from iptest.console_util import IronPythonInstance
    from sys import executable, exec_prefix
    from System import Environment

    extraArgs = ""
    if "-X:PreferComInteropAssembly" in Environment.GetCommandLineArgs():
        extraArgs += "-X:PreferComInteropAssembly"

    #Does it work from the commandline with negative cases?
    ipi = IronPythonInstance(executable, exec_prefix, extraArgs)
    AreEqual(ipi.Start(), True)
    try:
        ipi.ExecuteLine("from System import Type, Activator")
        ipi.ExecuteLine("import sys")
        ipi.ExecuteLine(
            "com_obj = Activator.CreateInstance(Type.GetTypeFromProgID('DlrComLibrary.DlrUniversalObj'))"
        )
        ipi.ExecuteLine("sys.stderr = sys.stdout"
                        )  #Limitation of ipi.  Cannot get sys.stderr...
        response = ipi.ExecuteLine("com_obj.m0(3)")
        Assert("Does not support a collection." in response)  #Merlin 324233
        Assert("EnvironmentError:" in response)  #Merlin 324233

    finally:
        ipi.End()
Beispiel #2
0
def test_from_cmdline():
    '''
    '''
    from iptest.console_util import IronPythonInstance
    from sys import executable, exec_prefix
    from System import Environment

    extraArgs = ""
    if "-X:PreferComInteropAssembly" in Environment.GetCommandLineArgs():
        extraArgs += "-X:PreferComInteropAssembly"

    #Does it work from the commandline with positive cases?
    ipi = IronPythonInstance(executable, exec_prefix, extraArgs)
    AreEqual(ipi.Start(), True)
    try:
        ipi.ExecuteLine("from System import Type, Activator")
        ipi.ExecuteLine(
            "com_obj = Activator.CreateInstance(Type.GetTypeFromProgID('DlrComLibrary.DlrUniversalObj'))"
        )

        #Dev10 409941
        Assert("System.__ComObject" in ipi.ExecuteLine("print com_obj"))
        AreEqual(ipi.ExecuteLine("print com_obj.m0()"), "None")
    finally:
        ipi.End()
Beispiel #3
0
    def test_dispatch_to_ReflectOptimized(self):
        """dispatch to a ReflectOptimized method"""

        from iptest.console_util import IronPythonInstance
        from System import Environment
        from sys import executable
        
        wkdir = self.test_dir
        
        if "-X:LightweightScopes" in Environment.GetCommandLineArgs():
            ipi = IronPythonInstance(executable, wkdir, "-X:LightweightScopes", "-X:BasicConsole")
        else:
            ipi = IronPythonInstance(executable, wkdir, "-X:BasicConsole")

        if (ipi.Start()):
            try:
                result = ipi.ExecuteLine("from iptest.ipunittest import load_ironpython_test")
                result = ipi.ExecuteLine("load_ironpython_test()")
                result = ipi.ExecuteLine("from IronPythonTest import DefaultParams")
                response = ipi.ExecuteLine("DefaultParams.FuncWithDefaults(1100, z=82)")
                self.assertEqual(response, '1184')
            finally:
                ipi.End()
#
#####################################################################################

from iptest.assert_util import *
skiptest("silverlight")
skiptest("win32")
from iptest.console_util import IronPythonInstance

remove_ironpython_dlls(testpath.public_testdir)

from sys import executable
from System import Environment
from sys import exec_prefix

extraArgs = ""
if "-X:LightweightScopes" in Environment.GetCommandLineArgs():
    extraArgs += " -X:LightweightScopes"


def test_strings():
    ipi = IronPythonInstance(executable, exec_prefix, extraArgs)
    AreEqual(ipi.Start(), True)

    # String exception
    response = ipi.ExecuteLine("raise 'foo'", True)
    AreEqual(
        response.replace("\r\r\n", "\n").replace("\r", ""),
        """Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes or instances, not str""")