FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/embed_tests/TestInstanceWrapping.cs at v3.1.0-rc0 · pythonnet/pythonnet · GitHub
pythonnet
pythonnet
Repository navigation
Code
Issues
147
(147)
Pull requests
11
(11)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestInstanceWrapping.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (49 loc) · 1.85 KB
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
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
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL