FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/tests/test_codec.py at v3.0.3 · pythonnet/pythonnet · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythonnet
/
pythonnet
Public
Notifications
You must be signed in to change notification settings
Fork
780
Star
5.5k
Code
Issues
153
Pull requests
12
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
tests
/
test_codec.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
115 lines (87 loc) · 2.99 KB
Breadcrumbs
pythonnet
/
tests
/
test_codec.py
Copy path
File metadata and controls
115 lines (87 loc) · 2.99 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# -*- coding: utf-8 -*-
"""Test conversions using codecs from client python code"""
import
pytest
import
Python
.
Runtime
import
Python
.
Test
as
Test
from
Python
.
Test
import
ListConversionTester
,
ListMember
,
CodecResetter
@
pytest
.
fixture
(
autouse
=
True
)
def
reset
():
CodecResetter
.
Reset
()
yield
CodecResetter
.
Reset
()
class
int_iterable
:
def
__init__
(
self
):
self
.
counter
=
0
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
if
self
.
counter
==
3
:
raise
StopIteration
self
.
counter
=
self
.
counter
+
1
return
self
.
counter
class
obj_iterable
:
def
__init__
(
self
):
self
.
counter
=
0
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
if
self
.
counter
==
3
:
raise
StopIteration
self
.
counter
=
self
.
counter
+
1
return
ListMember
(
self
.
counter
,
"Number "
+
str
(
self
.
counter
))
def
test_iterable
():
"""Test that a python iterable can be passed into a function that takes an
IEnumerable<object>"""
# Python.Runtime.Codecs.ListDecoder.Register()
# Python.Runtime.Codecs.SequenceDecoder.Register()
Python
.
Runtime
.
Codecs
.
IterableDecoder
.
Register
()
ob
=
ListConversionTester
()
iterable
=
int_iterable
()
assert
3
==
ob
.
GetLength
(
iterable
)
iterable2
=
obj_iterable
()
assert
3
==
ob
.
GetLength2
(
iterable2
)
def
test_sequence
():
Python
.
Runtime
.
Codecs
.
SequenceDecoder
.
Register
()
ob
=
ListConversionTester
()
tup
=
(
1
,
2
,
3
)
assert
3
==
ob
.
GetLength
(
tup
)
tup2
=
(
ListMember
(
1
,
"one"
),
ListMember
(
2
,
"two"
),
ListMember
(
3
,
"three"
))
assert
3
==
ob
.
GetLength
(
tup2
)
def
test_list
():
Python
.
Runtime
.
Codecs
.
SequenceDecoder
.
Register
()
ob
=
ListConversionTester
()
l
=
[
1
,
2
,
3
]
assert
3
==
ob
.
GetLength
(
l
)
l2
=
[
ListMember
(
1
,
"one"
),
ListMember
(
2
,
"two"
),
ListMember
(
3
,
"three"
)]
assert
3
==
ob
.
GetLength
(
l2
)
def
test_enum
():
Python
.
Runtime
.
PyObjectConversions
.
RegisterEncoder
(
Python
.
Runtime
.
Codecs
.
EnumPyIntCodec
.
Instance
)
assert
Test
.
ByteEnum
.
Zero
==
0
assert
Test
.
ByteEnum
.
One
==
1
assert
Test
.
ByteEnum
.
Two
==
2
assert
Test
.
SByteEnum
.
Zero
==
0
assert
Test
.
SByteEnum
.
One
==
1
assert
Test
.
SByteEnum
.
Two
==
2
assert
Test
.
ShortEnum
.
Zero
==
0
assert
Test
.
ShortEnum
.
One
==
1
assert
Test
.
ShortEnum
.
Two
==
2
assert
Test
.
UShortEnum
.
Zero
==
0
assert
Test
.
UShortEnum
.
One
==
1
assert
Test
.
UShortEnum
.
Two
==
2
assert
Test
.
IntEnum
.
Zero
==
0
assert
Test
.
IntEnum
.
One
==
1
assert
Test
.
IntEnum
.
Two
==
2
assert
Test
.
UIntEnum
.
Zero
==
0
assert
Test
.
UIntEnum
.
One
==
1
assert
Test
.
UIntEnum
.
Two
==
2
assert
Test
.
LongEnum
.
Zero
==
0
assert
Test
.
LongEnum
.
One
==
1
assert
Test
.
LongEnum
.
Two
==
2
assert
Test
.
ULongEnum
.
Zero
==
0
assert
Test
.
ULongEnum
.
One
==
1
assert
Test
.
ULongEnum
.
Two
==
2
assert
Test
.
LongEnum
.
Max
==
9223372036854775807
assert
Test
.
LongEnum
.
Min
==
-
9223372036854775808
assert
int
(
Test
.
ULongEnum
.
Max
)
==
18446744073709551615
Back
|
FazBrowse Home
|
New Git URL