FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/tests/test_interface.py at pypy · attackgithub/pythonnet · GitHub
attackgithub
pythonnet
Repository navigation
Code
Pull requests
Actions
Projects
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
72 lines (50 loc) · 2.3 KB
Breadcrumbs
pythonnet
/
src
/
tests
/
test_interface.py
Copy path
File metadata and controls
72 lines (50 loc) · 2.3 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
# -*- coding: utf-8 -*-
import
unittest
import
Python
.
Test
as
Test
from
_compat
import
DictProxyType
class
InterfaceTests
(
unittest
.
TestCase
):
"""Test CLR interface support."""
def
test_interface_standard_attrs
(
self
):
"""Test standard class attributes."""
from
Python
.
Test
import
IPublicInterface
self
.
assertTrue
(
IPublicInterface
.
__name__
==
'IPublicInterface'
)
self
.
assertTrue
(
IPublicInterface
.
__module__
==
'Python.Test'
)
self
.
assertTrue
(
isinstance
(
IPublicInterface
.
__dict__
,
DictProxyType
))
def
test_global_interface_visibility
(
self
):
"""Test visibility of module-level interfaces."""
from
Python
.
Test
import
IPublicInterface
self
.
assertTrue
(
IPublicInterface
.
__name__
==
'IPublicInterface'
)
with
self
.
assertRaises
(
ImportError
):
from
Python
.
Test
import
IInternalInterface
_
=
IInternalInterface
with
self
.
assertRaises
(
AttributeError
):
_
=
Test
.
IInternalInterface
def
test_nested_interface_visibility
(
self
):
"""Test visibility of nested interfaces."""
from
Python
.
Test
import
InterfaceTest
ob
=
InterfaceTest
.
IPublic
self
.
assertTrue
(
ob
.
__name__
==
'IPublic'
)
ob
=
InterfaceTest
.
IProtected
self
.
assertTrue
(
ob
.
__name__
==
'IProtected'
)
with
self
.
assertRaises
(
AttributeError
):
_
=
InterfaceTest
.
IInternal
with
self
.
assertRaises
(
AttributeError
):
_
=
InterfaceTest
.
IPrivate
def
test_explicit_cast_to_interface
(
self
):
"""Test explicit cast to an interface."""
from
Python
.
Test
import
InterfaceTest
ob
=
InterfaceTest
()
self
.
assertTrue
(
type
(
ob
).
__name__
==
'InterfaceTest'
)
self
.
assertTrue
(
hasattr
(
ob
,
'HelloProperty'
))
i1
=
Test
.
ISayHello1
(
ob
)
self
.
assertTrue
(
type
(
i1
).
__name__
==
'ISayHello1'
)
self
.
assertTrue
(
hasattr
(
i1
,
'SayHello'
))
self
.
assertTrue
(
i1
.
SayHello
()
==
'hello 1'
)
self
.
assertFalse
(
hasattr
(
i1
,
'HelloProperty'
))
i2
=
Test
.
ISayHello2
(
ob
)
self
.
assertTrue
(
type
(
i2
).
__name__
==
'ISayHello2'
)
self
.
assertTrue
(
i2
.
SayHello
()
==
'hello 2'
)
self
.
assertTrue
(
hasattr
(
i2
,
'SayHello'
))
self
.
assertFalse
(
hasattr
(
i2
,
'HelloProperty'
))
def
test_suite
():
return
unittest
.
makeSuite
(
InterfaceTests
)
Back
|
FazBrowse Home
|
New Git URL