FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/tests/test_interface.py at v2.5.1 · 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
/
src
/
tests
/
test_interface.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (47 loc) · 1.85 KB
Breadcrumbs
pythonnet
/
src
/
tests
/
test_interface.py
Copy path
File metadata and controls
69 lines (47 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
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
"""Test CLR interface support."""
import
Python
.
Test
as
Test
import
pytest
from
.
_compat
import
DictProxyType
def
test_interface_standard_attrs
():
"""Test standard class attributes."""
from
Python
.
Test
import
IPublicInterface
assert
IPublicInterface
.
__name__
==
'IPublicInterface'
assert
IPublicInterface
.
__module__
==
'Python.Test'
assert
isinstance
(
IPublicInterface
.
__dict__
,
DictProxyType
)
def
test_global_interface_visibility
():
"""Test visibility of module-level interfaces."""
from
Python
.
Test
import
IPublicInterface
assert
IPublicInterface
.
__name__
==
'IPublicInterface'
with
pytest
.
raises
(
ImportError
):
from
Python
.
Test
import
IInternalInterface
_
=
IInternalInterface
with
pytest
.
raises
(
AttributeError
):
_
=
Test
.
IInternalInterface
def
test_nested_interface_visibility
():
"""Test visibility of nested interfaces."""
from
Python
.
Test
import
InterfaceTest
ob
=
InterfaceTest
.
IPublic
assert
ob
.
__name__
==
'IPublic'
ob
=
InterfaceTest
.
IProtected
assert
ob
.
__name__
==
'IProtected'
with
pytest
.
raises
(
AttributeError
):
_
=
InterfaceTest
.
IInternal
with
pytest
.
raises
(
AttributeError
):
_
=
InterfaceTest
.
IPrivate
def
test_explicit_cast_to_interface
():
"""Test explicit cast to an interface."""
from
Python
.
Test
import
InterfaceTest
ob
=
InterfaceTest
()
assert
type
(
ob
).
__name__
==
'InterfaceTest'
assert
hasattr
(
ob
,
'HelloProperty'
)
i1
=
Test
.
ISayHello1
(
ob
)
assert
type
(
i1
).
__name__
==
'ISayHello1'
assert
hasattr
(
i1
,
'SayHello'
)
assert
i1
.
SayHello
()
==
'hello 1'
assert
not
hasattr
(
i1
,
'HelloProperty'
)
i2
=
Test
.
ISayHello2
(
ob
)
assert
type
(
i2
).
__name__
==
'ISayHello2'
assert
i2
.
SayHello
()
==
'hello 2'
assert
hasattr
(
i2
,
'SayHello'
)
assert
not
hasattr
(
i2
,
'HelloProperty'
)
Back
|
FazBrowse Home
|
New Git URL