FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-python/pythonFiles/testing_tools/unittest_discovery.py at main · usta/vscode-python · GitHub
usta
/
vscode-python
Public
forked from
microsoft/vscode-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-python
/
pythonFiles
/
testing_tools
/
unittest_discovery.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (53 loc) · 1.57 KB
Breadcrumbs
vscode-python
/
pythonFiles
/
testing_tools
/
unittest_discovery.py
Copy path
File metadata and controls
64 lines (53 loc) · 1.57 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
import
unittest
import
inspect
import
os
import
sys
import
traceback
start_dir
=
sys
.
argv
[
1
]
pattern
=
sys
.
argv
[
2
]
sys
.
path
.
insert
(
0
,
os
.
getcwd
())
def
get_sourceline
(
obj
):
try
:
s
,
n
=
inspect
.
getsourcelines
(
obj
)
except
:
try
:
# this handles `tornado` case we need a better
# way to get to the wrapped function.
# This is a temporary solution
s
,
n
=
inspect
.
getsourcelines
(
obj
.
orig_method
)
except
:
return
"*"
for
i
,
v
in
enumerate
(
s
):
if
v
.
strip
().
startswith
((
"def"
,
"async def"
)):
return
str
(
n
+
i
)
return
"*"
def
generate_test_cases
(
suite
):
for
test
in
suite
:
if
isinstance
(
test
,
unittest
.
TestCase
):
yield
test
else
:
for
test_case
in
generate_test_cases
(
test
):
yield
test_case
try
:
loader
=
unittest
.
TestLoader
()
suite
=
loader
.
discover
(
start_dir
,
pattern
=
pattern
)
print
(
"start"
)
# Don't remove this line
loader_errors
=
[]
for
s
in
generate_test_cases
(
suite
):
tm
=
getattr
(
s
,
s
.
_testMethodName
)
testId
=
s
.
id
()
if
testId
.
startswith
(
"unittest.loader._FailedTest"
):
loader_errors
.
append
(
s
.
_exception
)
else
:
print
(
testId
.
replace
(
"."
,
":"
)
+
":"
+
get_sourceline
(
tm
))
except
:
print
(
"=== exception start ==="
)
traceback
.
print_exc
()
print
(
"=== exception end ==="
)
for
error
in
loader_errors
:
try
:
print
(
"=== exception start ==="
)
print
(
error
.
msg
)
print
(
"=== exception end ==="
)
except
:
pass
Back
|
FazBrowse Home
|
New Git URL