GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pythonnet/src/embed_tests/TestInstanceWrapping.cs at master · pythonnet/pythonnet

Expand file tree

/

TestInstanceWrapping.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
56 lines (49 loc) · 1.85 KB
/

TestInstanceWrapping.cs

Copy path

File metadata and controls

56 lines (49 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Globalization;
using NUnit.Framework;
using Python.Runtime;
namespace Python.EmbeddingTest
{
public class TestInstanceWrapping
{
// regression test for https://github.com/pythonnet/pythonnet/issues/811
[Test]
public void OverloadResolution_UnknownToObject()
{
var overloaded = new Overloaded();
using (Py.GIL())
{
var o = overloaded.ToPython();
dynamic callWithSelf = PythonEngine.Eval("lambda o: o.ObjOrClass(object())");
callWithSelf(o);
Assert.That(overloaded.Value, Is.EqualTo(Overloaded.Object));
}
}
[Test]
public void WeakRefIsNone_AfterObjectIsGone()
{
using var makeref = Py.Import("weakref").GetAttr("ref");
var ub = new UriBuilder().ToPython();
using var weakref = makeref.Invoke(ub);
ub.Dispose();
Assert.That(weakref.Invoke().IsNone(), Is.True);
}
class Base {}
class Derived: Base { }
class Overloaded: Derived
{
public int Value { get; set; }
public void IntOrStr(int arg) => this.Value = arg;
public void IntOrStr(string arg) =>
this.Value = int.Parse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture);
public const int Object = 1;
public const int ConcreteClass = 2;
public void ObjOrClass(object _) => this.Value = Object;
public void ObjOrClass(Overloaded _) => this.Value = ConcreteClass;
public const int Base = ConcreteClass + 1;
public const int Derived = Base + 1;
public void BaseOrDerived(Base _) => this.Value = Base;
public void BaseOrDerived(Derived _) => this.Value = Derived;
}
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.