Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94021198
ctestresults.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Dec 3, 07:36
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Dec 5, 07:36 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22714005
Attached To
rAKA akantu
ctestresults.py
View Options
import
xml.etree.ElementTree
as
xml_etree
from
.results
import
Results
from
.
import
export
@export
class
CTestResults
:
STATUS
=
{
'passed'
:
Results
.
PASS
,
'failed'
:
Results
.
FAIL
}
def
__init__
(
self
,
filename
):
self
.
_file
=
open
(
filename
,
"r"
)
self
.
_etree
=
xml_etree
.
parse
(
self
.
_file
)
self
.
_root
=
self
.
_etree
.
getroot
()
self
.
test_format
=
'CTest'
def
__iter__
(
self
):
self
.
_tests
=
iter
(
self
.
_root
.
findall
(
'./Testing/Test'
))
return
self
def
__next__
(
self
):
class
Test
:
def
__init__
(
self
,
element
):
self
.
name
=
element
.
find
(
'Name'
)
.
text
self
.
path
=
element
.
find
(
'FullName'
)
.
text
self
.
status
=
CTestResults
.
STATUS
[
element
.
attrib
[
'Status'
]]
self
.
duration
=
float
(
element
.
find
(
"./Results/NamedMeasurement[@name='Execution Time']/Value"
)
.
text
)
def
__str__
(
self
):
return
f
'{self._name}: {self._status} in {self._duration}'
test
=
next
(
self
.
_tests
)
#print(test.find('Name'))
#while not test.find('Name'):
# test = next(self._tests)
return
Test
(
test
)
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
self
.
_file
.
close
()
def
__enter__
(
self
):
return
self
Event Timeline
Log In to Comment