Add mypy tests through ament_mypy
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
parent
aa59950fe2
commit
9450bfeea9
15 changed files with 117 additions and 23 deletions
|
@ -13,6 +13,7 @@
|
|||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_mypy</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
<test_depend>ament_xmllint</test_depend>
|
||||
<test_depend>python3-pytest</test_depend>
|
||||
|
|
22
tracetools_read/test/test_mypy.py
Normal file
22
tracetools_read/test/test_mypy.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2019 Canonical Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_mypy.main import main
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.mypy
|
||||
@pytest.mark.linter
|
||||
def test_mypy():
|
||||
assert main(argv=[]) == 0, 'Found errors'
|
|
@ -23,9 +23,6 @@ import babeltrace
|
|||
from . import DictEvent
|
||||
|
||||
|
||||
BabeltraceEvent = babeltrace.babeltrace.Event
|
||||
|
||||
|
||||
def is_trace_directory(path: str) -> bool:
|
||||
"""
|
||||
Check recursively if a path is a trace directory.
|
||||
|
@ -42,7 +39,7 @@ def is_trace_directory(path: str) -> bool:
|
|||
return traces is not None and len(traces) > 0
|
||||
|
||||
|
||||
def get_trace_ctf_events(trace_directory: str) -> Iterable[BabeltraceEvent]:
|
||||
def get_trace_ctf_events(trace_directory: str) -> Iterable[babeltrace.babeltrace.Event]:
|
||||
"""
|
||||
Get the events of a trace.
|
||||
|
||||
|
@ -61,7 +58,10 @@ def get_trace_events(trace_directory: str) -> List[DictEvent]:
|
|||
:param trace_directory: the path to the main/top trace directory
|
||||
:return: events
|
||||
"""
|
||||
return [event_to_dict(event) for event in get_trace_ctf_events(trace_directory)]
|
||||
events: List[DictEvent] = [
|
||||
event_to_dict(event) for event in get_trace_ctf_events(trace_directory)
|
||||
]
|
||||
return events
|
||||
|
||||
|
||||
# List of ignored CTF fields
|
||||
|
@ -82,7 +82,7 @@ _IGNORED_FIELDS = [
|
|||
_DISCARD = 'events_discarded'
|
||||
|
||||
|
||||
def event_to_dict(event: BabeltraceEvent) -> DictEvent:
|
||||
def event_to_dict(event: babeltrace.babeltrace.Event) -> DictEvent:
|
||||
"""
|
||||
Convert name, timestamp, and all other keys except those in IGNORED_FIELDS into a dictionary.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue