Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e8ea7a6
1776 Inherit Generic Virtual Method Bug: Unit Test
rmadsen-ks Apr 27, 2022
691f207
1776 Inherit Generic Virtual Method Bug: Fix
rmadsen-ks Apr 28, 2022
e27ad8c
1774-ClassWithoutnamespace
rmadsen-ks Apr 29, 2022
f1fa696
better support for multiple inheritance
rmadsen-ks May 3, 2022
6f0b354
Fixed issue with protected constructors and classes with no constructor
rmadsen-ks May 3, 2022
3963621
Added supporr for class/property/method attributes.
rmadsen-ks May 5, 2022
4e0d003
- Expanded the way attributes amy be added
rmadsen-ks May 5, 2022
ea598a2
added support for creating abstract classes using a __clr_abstract__ …
rmadsen-ks May 6, 2022
d6abbb2
Improved AttributeError when looking for a symbol that does not exist…
rmadsen-ks May 24, 2022
2a84675
Added test to detect an issue with object construction.
rmadsen-ks Jun 28, 2022
172c642
got rid of a few deprecation warnings that pollute GitHub code review
lostmsu Jun 30, 2022
32d15eb
docs: Fix a few typos
timgates42 Jul 16, 2022
9eaf35f
Added support for marking properties with python types.
rmadsen-ks Sep 2, 2022
9ed94f6
Fixed issue calling base-base class implementation of methods.
rmadsen-ks Sep 2, 2022
da146d9
Merged with Pythonnet 3.0 RC.6.
rmadsen-ks Oct 28, 2022
b280b1b
Fixed bug related to converting number to a string
rmadsen-ks Oct 28, 2022
61c5d99
Added support for Python 3.11.
rmadsen-ks Oct 28, 2022
ed89819
Merge remote-tracking branch 'github/master'
rmadsen-ks Nov 14, 2023
56c8a39
Merge branch 'master' of github.com:pythonnet/pythonnet
rmadsen-ks Nov 14, 2023
e986114
Merge remote-tracking branch 'github/master'
rmadsen-ks Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added test to detect an issue with object construction.
  • Loading branch information
rmadsen-ks committed Oct 26, 2022
commit 2a84675fbdebfcda47e4d05d09af328c6b44967d
26 changes: 26 additions & 0 deletions src/testing/subclasstest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Threading;

using Python.Runtime;

namespace Python.Test
{
public interface IInterfaceTest
Expand Down Expand Up @@ -215,6 +217,30 @@ public static object InvokeCtor(Type t)
return obj;
}

public object TestObj { get; set; }

public static object TestOnType(Type t)
{
using (Py.GIL())
{
var obj = (SimpleClass) Activator.CreateInstance(t);
//obj = obj.ToPython().As<SimpleClass>();
obj.TestObj = new object();
var py = obj.ToPython();
var man = py.As<SimpleClass>();
if (!ReferenceEquals(man, obj))
throw new Exception("Same object expected");
var setObj = py.GetAttr("TestObj").As<object>();
if (setObj == null)
throw new NullReferenceException();
if (ReferenceEquals(setObj, obj.TestObj) == false)
throw new Exception("!!");


return obj;
}
}

public static void Pause()
{

Expand Down
23 changes: 22 additions & 1 deletion tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,27 @@ class ClassWithAttributes3(ISimpleInterface, SimpleClass):

c = ClassWithAttributes2()
c2 = ClassWithAttributes3()

def test_subclass_ctor():
import clr
class SubClass0(SimpleClass):
pass
class SubClass1(SubClass0):
def __init__(self):
super().__init__()
class SubClass2(SubClass1):
__namespace__ = "TestModule"
def __init__(self):
super().__init__()
SimpleClass.TestOnType(SubClass0)
SimpleClass.TestOnType(SubClass1)
SimpleClass.TestOnType(SubClass2)

def test_more_subclasses():
import clr
class SubClass1(SimpleClass):
class SubClass0(SimpleClass):
pass
class SubClass1(SubClass0):
X = clr.property(Double, 1.0)
def __init__(self):
super().__init__()
Expand All @@ -379,6 +397,9 @@ def __init__(self):
super().__init__()
def IncrementThing(self):
return 6;
SimpleClass.TestOnType(SubClass0)
SimpleClass.TestOnType(SubClass1)
SimpleClass.TestOnType(SubClass2)
obj = SimpleClass.InvokeCtor(SubClass2)

obj2 = SubClass2()
Expand Down