FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonVSCode/pythonFiles/testing_tools/adapter/info.py at master · iVerb/pythonVSCode · GitHub
iVerb
/
pythonVSCode
Public
forked from
DonJayamanne/pythonVSCode
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
pythonVSCode
/
pythonFiles
/
testing_tools
/
adapter
/
info.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (100 loc) · 4.24 KB
Breadcrumbs
pythonVSCode
/
pythonFiles
/
testing_tools
/
adapter
/
info.py
Copy path
File metadata and controls
119 lines (100 loc) · 4.24 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from
collections
import
namedtuple
class
TestPath
(
namedtuple
(
'TestPath'
,
'root relfile func sub'
)):
"""Where to find a single test."""
def
__new__
(
cls
,
root
,
relfile
,
func
,
sub
=
None
):
self
=
super
(
TestPath
,
cls
).
__new__
(
cls
,
str
(
root
)
if
root
else
None
,
str
(
relfile
)
if
relfile
else
None
,
str
(
func
)
if
func
else
None
,
[
str
(
s
)
for
s
in
sub
]
if
sub
else
None
,
)
return
self
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
self
.
root
is
None
:
raise
TypeError
(
'missing id'
)
if
self
.
relfile
is
None
:
raise
TypeError
(
'missing kind'
)
# self.func may be None (e.g. for doctests).
# self.sub may be None.
class
ParentInfo
(
namedtuple
(
'ParentInfo'
,
'id kind name root relpath parentid'
)):
KINDS
=
(
'folder'
,
'file'
,
'suite'
,
'function'
,
'subtest'
)
def
__new__
(
cls
,
id
,
kind
,
name
,
root
=
None
,
relpath
=
None
,
parentid
=
None
):
self
=
super
(
ParentInfo
,
cls
).
__new__
(
cls
,
id
=
str
(
id
)
if
id
else
None
,
kind
=
str
(
kind
)
if
kind
else
None
,
name
=
str
(
name
)
if
name
else
None
,
root
=
str
(
root
)
if
root
else
None
,
relpath
=
str
(
relpath
)
if
relpath
else
None
,
parentid
=
str
(
parentid
)
if
parentid
else
None
,
)
return
self
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
self
.
id
is
None
:
raise
TypeError
(
'missing id'
)
if
self
.
kind
is
None
:
raise
TypeError
(
'missing kind'
)
if
self
.
kind
not
in
self
.
KINDS
:
raise
ValueError
(
'unsupported kind {!r}'
.
format
(
self
.
kind
))
if
self
.
name
is
None
:
raise
TypeError
(
'missing name'
)
if
self
.
root
is
None
:
if
self
.
parentid
is
not
None
or
self
.
kind
!=
'folder'
:
raise
TypeError
(
'missing root'
)
if
self
.
relpath
is
not
None
:
raise
TypeError
(
'unexpected relpath {}'
.
format
(
self
.
relpath
))
elif
self
.
parentid
is
None
:
raise
TypeError
(
'missing parentid'
)
elif
self
.
relpath
is
None
and
self
.
kind
in
(
'folder'
,
'file'
):
raise
TypeError
(
'missing relpath'
)
class
TestInfo
(
namedtuple
(
'TestInfo'
,
'id name path source markers parentid kind'
)):
"""Info for a single test."""
MARKERS
=
(
'skip'
,
'skip-if'
,
'expected-failure'
)
KINDS
=
(
'function'
,
'doctest'
)
def
__new__
(
cls
,
id
,
name
,
path
,
source
,
markers
,
parentid
,
kind
=
'function'
):
self
=
super
(
TestInfo
,
cls
).
__new__
(
cls
,
str
(
id
)
if
id
else
None
,
str
(
name
)
if
name
else
None
,
path
or
None
,
str
(
source
)
if
source
else
None
,
[
str
(
marker
)
for
marker
in
markers
or
()],
str
(
parentid
)
if
parentid
else
None
,
str
(
kind
)
if
kind
else
None
,
)
return
self
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
self
.
id
is
None
:
raise
TypeError
(
'missing id'
)
if
self
.
name
is
None
:
raise
TypeError
(
'missing name'
)
if
self
.
path
is
None
:
raise
TypeError
(
'missing path'
)
if
self
.
source
is
None
:
raise
TypeError
(
'missing source'
)
else
:
srcfile
,
_
,
lineno
=
self
.
source
.
rpartition
(
':'
)
if
not
srcfile
or
not
lineno
or
int
(
lineno
)
<
0
:
raise
ValueError
(
'bad source {!r}'
.
format
(
self
.
source
))
if
self
.
markers
:
badmarkers
=
[
m
for
m
in
self
.
markers
if
m
not
in
self
.
MARKERS
]
if
badmarkers
:
raise
ValueError
(
'unsupported markers {!r}'
.
format
(
badmarkers
))
if
self
.
parentid
is
None
:
raise
TypeError
(
'missing parentid'
)
if
self
.
kind
is
None
:
raise
TypeError
(
'missing kind'
)
elif
self
.
kind
not
in
self
.
KINDS
:
raise
ValueError
(
'unsupported kind {!r}'
.
format
(
self
.
kind
))
@
property
def
root
(
self
):
return
self
.
path
.
root
@
property
def
srcfile
(
self
):
return
self
.
source
.
rpartition
(
':'
)[
0
]
@
property
def
lineno
(
self
):
return
int
(
self
.
source
.
rpartition
(
':'
)[
-
1
])
Back
|
FazBrowse Home
|
New Git URL