FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/tests/test_mp_length.py at python-3.13 · generalloki/pythonnet · GitHub
generalloki
pythonnet
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
tests
/
test_mp_length.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (52 loc) · 2.01 KB
Breadcrumbs
pythonnet
/
tests
/
test_mp_length.py
Copy path
File metadata and controls
63 lines (52 loc) · 2.01 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
# -*- coding: utf-8 -*-
"""Test __len__ for .NET classes implementing ICollection/ICollection<T>."""
import
System
import
pytest
from
Python
.
Test
import
MpLengthCollectionTest
,
MpLengthExplicitCollectionTest
,
MpLengthGenericCollectionTest
,
MpLengthExplicitGenericCollectionTest
def
test_simple___len__
():
"""Test __len__ for simple ICollection implementers"""
import
System
import
System
.
Collections
.
Generic
l
=
System
.
Collections
.
Generic
.
List
[
int
]()
assert
len
(
l
)
==
0
l
.
Add
(
5
)
l
.
Add
(
6
)
assert
len
(
l
)
==
2
d
=
System
.
Collections
.
Generic
.
Dictionary
[
int
,
int
]()
assert
len
(
d
)
==
0
d
.
Add
(
4
,
5
)
assert
len
(
d
)
==
1
a
=
System
.
Array
[
int
]([
0
,
1
,
2
,
3
])
assert
len
(
a
)
==
4
def
test_custom_collection___len__
():
"""Test __len__ for custom collection class"""
s
=
MpLengthCollectionTest
()
assert
len
(
s
)
==
3
def
test_custom_collection_explicit___len__
():
"""Test __len__ for custom collection class that explicitly implements ICollection"""
s
=
MpLengthExplicitCollectionTest
()
assert
len
(
s
)
==
2
def
test_custom_generic_collection___len__
():
"""Test __len__ for custom generic collection class"""
s
=
MpLengthGenericCollectionTest
[
int
]()
s
.
Add
(
1
)
s
.
Add
(
2
)
assert
len
(
s
)
==
2
def
test_custom_generic_collection_explicit___len__
():
"""Test __len__ for custom generic collection that explicity implements ICollection<T>"""
s
=
MpLengthExplicitGenericCollectionTest
[
int
]()
s
.
Add
(
1
)
s
.
Add
(
10
)
assert
len
(
s
)
==
2
def
test_len_through_interface_generic
():
"""Test __len__ for ICollection<T>"""
import
System
.
Collections
.
Generic
l
=
System
.
Collections
.
Generic
.
List
[
int
]()
coll
=
System
.
Collections
.
Generic
.
ICollection
[
int
](
l
)
assert
len
(
coll
)
==
0
def
test_len_through_interface
():
"""Test __len__ for ICollection"""
import
System
.
Collections
l
=
System
.
Collections
.
ArrayList
()
coll
=
System
.
Collections
.
ICollection
(
l
)
assert
len
(
coll
)
==
0
Back
|
FazBrowse Home
|
New Git URL