-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest_inspect.py
More file actions
37 lines (32 loc) · 1.15 KB
/
test_inspect.py
File metadata and controls
37 lines (32 loc) · 1.15 KB
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
"""
Tests for functions in inspect submodule.
"""
import re
from scyjava import inspect
from scyjava.config import mode, Mode
class TestInspect(object):
"""
Test scyjava.inspect convenience functions.
"""
def test_inspect_members(self):
if mode == Mode.JEP:
# JEP does not support the jclass function.
return
members = []
inspect.members("java.lang.Iterable", writer=members.append)
expected = [
"Source code URL: https://github.com/openjdk/jdk/blob/"
".../share/classes/java/lang/Iterable.java",
" * indicates static modifier",
"java.util.Iterator = iterator()",
"java.util.Spliterator = spliterator()",
"void = forEach(java.util.function.Consumer)",
"",
"",
]
pattern = (
r"(https://github.com/openjdk/jdk/blob/)"
r"[^ ]*(/share/classes/java/lang/Iterable\.java)"
)
members_string = re.sub(pattern, r"\1...\2", "".join(members))
assert members_string.split("\n") == expected