Does it work correctly under NUnit if you disable shadow copying? On Mon, Sep 29, 2008 at 10:41 AM, Fernando Correia < [EMAIL PROTECTED]> wrote:
> Dino, thanks for your support. > > The modified code still aborts under NUnit, so it is not related to > the configuration. The program runs correctly outside NUnit, but > raises an InvalidProgramException when executed as a unit test. > > I had a similar problem with a previous version of IronPython that > disappeared in another release. Granted that NUnit must be doing > something to the execution context, but it would really be a shame if > code that uses IronPython could not be tested under NUnit. > > Please notice that until Beta 4 this kind of test was working. The > exception started with Beta 5. > > Regards. > > using System; > using System.Collections.Generic; > using System.Diagnostics; > using System.Text; > using Microsoft.Scripting.Hosting; > using Microsoft.Scripting; > using IronPython.Hosting; > using NUnit.Framework; > > namespace HelloDLRWorld > { > [TestFixture] > public class DlrTest2 > { > public static void Main(string[] args) > { > var test = new DlrTest2(); > test.ImportTest(); > } > > [Test] > public void ImportTest() > { > ScriptRuntime runtime = Python.CreateRuntime(); > runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > runtime.LoadAssembly(typeof(System.Double).Assembly); > ScriptEngine pyEng = runtime.GetEngine("IronPython"); > ScriptSource source = pyEng.CreateScriptSourceFromString(@" > import System.Diagnostics > output='hello world from DLR/IronPython!' > System.Diagnostics.Debug.WriteLine(output) > ", SourceCodeKind.Statements); > ScriptScope scope = pyEng.CreateScope(); > source.Execute(scope); > object outputMsg = scope.GetVariable("output"); > Console.WriteLine(outputMsg.ToString()); > } > } > } > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com