IronRuby.Tests.Tests.PythonInterop4 C# (CSharp) Method

PythonInterop4() public method

public PythonInterop4 ( ) : void
return void
        public void PythonInterop4() {
            if (!_driver.RunPython) return;

            var py = Runtime.GetEngine("python");

            var scope = py.CreateScope();
            py.Execute(@"
def get_python_class():
  class C(object): 
    x = 123  
    def __str__(self):
      return 'this is C'
    

  return C()
", scope);

            Engine.Execute(@"self.c = get_python_class.call", scope);

            var s = Engine.Execute<MutableString>(@"c.to_str", scope);
            Assert(s.ToString() == @"this is C");

            var i = Engine.Execute<int>(@"c.x", scope);
            Assert(i == 123);

            // TODO: test
            // c.y, where y is a delegate
            // c.p, where p is a Ruby Proc
        }
Tests