From f5567ea88d172767b34373bc6e402da8bfd85ef8 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 21 Jun 2022 16:29:32 -0400 Subject: [PATCH] Remove `skip-string-normalization` in Python formatter config Initially, this option was added to follow existing coding style of the project. It was recently agreed upon that relying on `black` completely would be simpler. Signed-off-by: Francis Deslauriers Change-Id: Ic4f7fc672502d512c10f107c254cec18c28a7710 Reviewed-on: https://review.lttng.org/c/babeltrace/+/8518 CI-Build: Simon Marchi Tested-by: jenkins Reviewed-by: Simon Marchi --- doc/bindings/python/ext/bt2sphinxurl.py | 32 +- doc/bindings/python/source/conf.py | 14 +- pyproject.toml | 1 - src/bindings/python/bt2/bt2/__init__.py | 66 +- src/bindings/python/bt2/bt2/component.py | 64 +- .../python/bt2/bt2/component_descriptor.py | 2 +- src/bindings/python/bt2/bt2/error.py | 8 +- src/bindings/python/bt2/bt2/field.py | 88 +-- src/bindings/python/bt2/bt2/field_class.py | 110 +-- src/bindings/python/bt2/bt2/graph.py | 16 +- .../python/bt2/bt2/integer_range_set.py | 4 +- src/bindings/python/bt2/bt2/interrupter.py | 2 +- src/bindings/python/bt2/bt2/message.py | 10 +- .../python/bt2/bt2/message_iterator.py | 58 +- src/bindings/python/bt2/bt2/mip.py | 8 +- src/bindings/python/bt2/bt2/object.py | 2 +- src/bindings/python/bt2/bt2/plugin.py | 10 +- src/bindings/python/bt2/bt2/port.py | 4 +- src/bindings/python/bt2/bt2/py_plugin.py | 12 +- src/bindings/python/bt2/bt2/query_executor.py | 8 +- src/bindings/python/bt2/bt2/stream.py | 4 +- src/bindings/python/bt2/bt2/stream_class.py | 20 +- src/bindings/python/bt2/bt2/trace.py | 12 +- src/bindings/python/bt2/bt2/trace_class.py | 50 +- .../bt2/trace_collection_message_iterator.py | 84 +-- src/bindings/python/bt2/bt2/utils.py | 10 +- src/bindings/python/bt2/bt2/value.py | 42 +- src/bindings/python/bt2/bt2/version.py.in | 2 +- src/bindings/python/bt2/setup.py.in | 64 +- tests/bindings/python/bt2/test_clock_class.py | 36 +- tests/bindings/python/bt2/test_component.py | 22 +- .../python/bt2/test_component_class.py | 52 +- .../python/bt2/test_component_descriptor.py | 10 +- tests/bindings/python/bt2/test_connection.py | 36 +- tests/bindings/python/bt2/test_error.py | 56 +- tests/bindings/python/bt2/test_event.py | 180 ++--- tests/bindings/python/bt2/test_event_class.py | 36 +- tests/bindings/python/bt2/test_field.py | 676 +++++++++--------- tests/bindings/python/bt2/test_field_class.py | 402 +++++------ tests/bindings/python/bt2/test_graph.py | 208 +++--- .../python/bt2/test_integer_range_set.py | 16 +- tests/bindings/python/bt2/test_interrupter.py | 2 +- tests/bindings/python/bt2/test_message.py | 68 +- .../python/bt2/test_message_iterator.py | 192 ++--- tests/bindings/python/bt2/test_mip.py | 4 +- tests/bindings/python/bt2/test_package.py | 346 ++++----- tests/bindings/python/bt2/test_packet.py | 28 +- tests/bindings/python/bt2/test_plugin.py | 48 +- tests/bindings/python/bt2/test_port.py | 392 +++++----- .../python/bt2/test_query_executor.py | 64 +- tests/bindings/python/bt2/test_stream.py | 14 +- .../bindings/python/bt2/test_stream_class.py | 22 +- tests/bindings/python/bt2/test_trace.py | 42 +- tests/bindings/python/bt2/test_trace_class.py | 16 +- .../test_trace_collection_message_iterator.py | 212 +++--- tests/bindings/python/bt2/test_value.py | 400 +++++------ tests/bindings/python/bt2/utils.py | 86 +-- .../grouping/bt_plugin_test.py | 42 +- .../params-log-level/bt_plugin_test.py | 42 +- .../bt_plugin_test_cli_exit_status.py | 6 +- .../list-plugins/bt_plugin_list_plugins.py | 8 +- tests/data/cli/params/bt_plugin_params.py | 2 +- tests/data/cli/query/bt_plugin_query.py | 6 +- .../bt_plugin_test_debug_info.py | 14 +- .../flt.utils.muxer/bt_plugin_muxer_test.py | 112 +-- .../bt_plugin_trimmer_test.py | 22 +- .../assume-single-trace/bt_plugin_foo.py | 6 +- .../sink.ctf.fs/stream-names/bt_plugin_foo.py | 10 +- .../sink.text.pretty/bt_plugin_pretty_test.py | 20 +- .../src.ctf.lttng-live/lttng_live_server.py | 206 +++--- tests/lib/conds/test.py | 34 +- tests/plugins/sink.text.pretty/test_pretty.py | 4 +- .../query/test_query_support_info.py | 80 +-- .../src.ctf.fs/query/test_query_trace_info.py | 102 +-- .../bt_plugin_test_python_plugin_provider.py | 10 +- .../test_python_plugin_provider.py | 18 +- tests/utils/python/cli_params_to_string.py | 10 +- tests/utils/python/split_sort_compare.py | 6 +- tests/utils/python/testrunner.py | 24 +- 79 files changed, 2628 insertions(+), 2629 deletions(-) diff --git a/doc/bindings/python/ext/bt2sphinxurl.py b/doc/bindings/python/ext/bt2sphinxurl.py index b3e2608a..d76cc1c7 100644 --- a/doc/bindings/python/ext/bt2sphinxurl.py +++ b/doc/bindings/python/ext/bt2sphinxurl.py @@ -44,10 +44,10 @@ def _bt2man_role( bt2_version, name, rawtext, text, lineno, inliner, options=None, content=None ): # match a manual page reference - m = re.match(r'^([a-zA-Z0-9_.:-]+)\(([a-zA-Z0-9]+)\)$', text) + m = re.match(r"^([a-zA-Z0-9_.:-]+)\(([a-zA-Z0-9]+)\)$", text) if not m: - msg = 'Cannot parse manual page reference `{}`'.format(text) + msg = "Cannot parse manual page reference `{}`".format(text) inliner.reporter.severe(msg, line=lineno) return [inliner.problematic(rawtext, rawtext, msg)], [msg] @@ -57,17 +57,17 @@ def _bt2man_role( # create nodes: `ret_node` is the node to return page_node = docutils.nodes.strong(rawtext, page) - vol_node = docutils.nodes.inline(rawtext, '({})'.format(vol)) - man_node = docutils.nodes.inline(rawtext, '', page_node, vol_node) - ret_node = docutils.nodes.literal(rawtext, '', man_node) + vol_node = docutils.nodes.inline(rawtext, "({})".format(vol)) + man_node = docutils.nodes.inline(rawtext, "", page_node, vol_node) + ret_node = docutils.nodes.literal(rawtext, "", man_node) - if page.startswith('babeltrace2'): + if page.startswith("babeltrace2"): # Babeltrace 2 manual page: wrap `ret_node` with an external # link node - url_tmpl = 'https://babeltrace.org/docs/v{ver}/man{vol}/{page}.{vol}/' + url_tmpl = "https://babeltrace.org/docs/v{ver}/man{vol}/{page}.{vol}/" url = url_tmpl.format(ver=bt2_version, vol=vol, page=page) ret_node = docutils.nodes.reference( - rawtext, '', ret_node, internal=False, refuri=url + rawtext, "", ret_node, internal=False, refuri=url ) return [ret_node], [] @@ -77,17 +77,17 @@ def _bt2link_role( bt2_version, name, rawtext, text, lineno, inliner, options=None, content=None ): # match link text and URL - m = re.match(r'^([^<]+) <([^>]+)>$', text) + m = re.match(r"^([^<]+) <([^>]+)>$", text) if not m: - msg = 'Cannot parse link template `{}`'.format(text) + msg = "Cannot parse link template `{}`".format(text) inliner.reporter.severe(msg, line=lineno) return [inliner.problematic(rawtext, rawtext, msg)], [msg] link_text = m.group(1) # replace `@ver@` with the project's version - url = m.group(2).replace('@ver@', bt2_version) + url = m.group(2).replace("@ver@", bt2_version) # create and return an external link node node = docutils.nodes.reference(rawtext, link_text, internal=False, refuri=url) @@ -97,13 +97,13 @@ def _bt2link_role( def _add_roles(app): # add the extension's roles; the role functions above expect the # project's version as their first parameter - app.add_role('bt2man', functools.partial(_bt2man_role, app.config.version)) - app.add_role('bt2link', functools.partial(_bt2link_role, app.config.version)) + app.add_role("bt2man", functools.partial(_bt2man_role, app.config.version)) + app.add_role("bt2link", functools.partial(_bt2link_role, app.config.version)) def setup(app): - app.connect('builder-inited', _add_roles) + app.connect("builder-inited", _add_roles) return { - 'version': app.config.version, - 'parallel_read_safe': True, + "version": app.config.version, + "parallel_read_safe": True, } diff --git a/doc/bindings/python/source/conf.py b/doc/bindings/python/source/conf.py index 859ae57a..148cc92a 100644 --- a/doc/bindings/python/source/conf.py +++ b/doc/bindings/python/source/conf.py @@ -6,17 +6,17 @@ import bt2 import re # project -project = 'Babeltrace 2 Python bindings' -copyright = '2020, EfficiOS, Inc' -author = 'EfficiOS, Inc' +project = "Babeltrace 2 Python bindings" +copyright = "2020, EfficiOS, Inc" +author = "EfficiOS, Inc" release = bt2.__version__ -version = re.match(r'^\d+\.\d+', release).group(0) +version = re.match(r"^\d+\.\d+", release).group(0) # index -master_doc = 'index' +master_doc = "index" # extensions -extensions = ['bt2sphinxurl'] +extensions = ["bt2sphinxurl"] # theme -html_theme = 'alabaster' +html_theme = "alabaster" diff --git a/pyproject.toml b/pyproject.toml index 2b8c201e..39d5b4a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,4 @@ [tool.black] - skip-string-normalization = true include = ''' ( \.pyi?$ diff --git a/src/bindings/python/bt2/bt2/__init__.py b/src/bindings/python/bt2/bt2/__init__.py index 9ed080e8..38bb9b17 100644 --- a/src/bindings/python/bt2/bt2/__init__.py +++ b/src/bindings/python/bt2/bt2/__init__.py @@ -186,38 +186,38 @@ if (sys.version_info.major, sys.version_info.minor) != (3, 4): del globals()[name] # remove private module names from the package - _del_global_name('_native_bt') - _del_global_name('clock_class') - _del_global_name('clock_snapshot') - _del_global_name('component') - _del_global_name('connection') - _del_global_name('error') - _del_global_name('event') - _del_global_name('event_class') - _del_global_name('field') - _del_global_name('field_class') - _del_global_name('field_path') - _del_global_name('graph') - _del_global_name('integer_range_set') - _del_global_name('interrupter') - _del_global_name('logging') - _del_global_name('message') - _del_global_name('message_iterator') - _del_global_name('native_bt') - _del_global_name('object') - _del_global_name('packet') - _del_global_name('plugin') - _del_global_name('port') - _del_global_name('py_plugin') - _del_global_name('query_executor') - _del_global_name('stream') - _del_global_name('stream_class') - _del_global_name('trace') - _del_global_name('trace_class') - _del_global_name('trace_collection_message_iterator') - _del_global_name('utils') - _del_global_name('value') - _del_global_name('version') + _del_global_name("_native_bt") + _del_global_name("clock_class") + _del_global_name("clock_snapshot") + _del_global_name("component") + _del_global_name("connection") + _del_global_name("error") + _del_global_name("event") + _del_global_name("event_class") + _del_global_name("field") + _del_global_name("field_class") + _del_global_name("field_path") + _del_global_name("graph") + _del_global_name("integer_range_set") + _del_global_name("interrupter") + _del_global_name("logging") + _del_global_name("message") + _del_global_name("message_iterator") + _del_global_name("native_bt") + _del_global_name("object") + _del_global_name("packet") + _del_global_name("plugin") + _del_global_name("port") + _del_global_name("py_plugin") + _del_global_name("query_executor") + _del_global_name("stream") + _del_global_name("stream_class") + _del_global_name("trace") + _del_global_name("trace_class") + _del_global_name("trace_collection_message_iterator") + _del_global_name("utils") + _del_global_name("value") + _del_global_name("version") # remove private `_del_global_name` name from the package del _del_global_name @@ -228,7 +228,7 @@ del sys class _MemoryError(_Error): - '''Raised when an operation fails due to memory issues.''' + """Raised when an operation fails due to memory issues.""" class UnknownObject(Exception): diff --git a/src/bindings/python/bt2/bt2/component.py b/src/bindings/python/bt2/bt2/component.py index 5395e0b6..7ae6fe25 100644 --- a/src/bindings/python/bt2/bt2/component.py +++ b/src/bindings/python/bt2/bt2/component.py @@ -177,7 +177,7 @@ class _ComponentConst: ) def __eq__(self, other): - if not hasattr(other, 'addr'): + if not hasattr(other, "addr"): return False return self.addr == other.addr @@ -329,7 +329,7 @@ def _trim_docstring(docstring): lines = docstring.expandtabs().splitlines() if len(lines) == 0: - return '' + return "" indent = sys.maxsize @@ -352,7 +352,7 @@ def _trim_docstring(docstring): while trimmed and not trimmed[0]: trimmed.pop(0) - return '\n'.join(trimmed) + return "\n".join(trimmed) # Metaclass for component classes defined by Python code. @@ -437,22 +437,22 @@ class _UserComponentType(type): # skip our own bases; they are never directly instantiated by the user own_bases = ( - '_UserComponent', - '_UserFilterSinkComponent', - '_UserSourceComponent', - '_UserFilterComponent', - '_UserSinkComponent', + "_UserComponent", + "_UserFilterSinkComponent", + "_UserSourceComponent", + "_UserFilterComponent", + "_UserSinkComponent", ) if class_name in own_bases: return - comp_cls_name = kwargs.get('name', class_name) + comp_cls_name = kwargs.get("name", class_name) utils._check_str(comp_cls_name) comp_cls_descr = None comp_cls_help = None - if hasattr(cls, '__doc__') and cls.__doc__ is not None: + if hasattr(cls, "__doc__") and cls.__doc__ is not None: utils._check_str(cls.__doc__) docstring = _trim_docstring(cls.__doc__) lines = docstring.splitlines() @@ -461,9 +461,9 @@ class _UserComponentType(type): comp_cls_descr = lines[0] if len(lines) >= 3: - comp_cls_help = '\n'.join(lines[2:]) + comp_cls_help = "\n".join(lines[2:]) - iter_cls = kwargs.get('message_iterator_class') + iter_cls = kwargs.get("message_iterator_class") if _UserSourceComponent in bases: _UserComponentType._bt_set_iterator_class(cls, iter_cls) @@ -476,7 +476,7 @@ class _UserComponentType(type): cls, comp_cls_name, comp_cls_descr, comp_cls_help ) elif _UserSinkComponent in bases: - if not hasattr(cls, '_user_consume'): + if not hasattr(cls, "_user_consume"): raise bt2._IncompleteUserClass( "cannot create component class '{}': missing a _user_consume() method".format( class_name @@ -521,7 +521,7 @@ class _UserComponentType(type): def __call__(cls, *args, **kwargs): raise RuntimeError( - 'cannot directly instantiate a user component from a Python module' + "cannot directly instantiate a user component from a Python module" ) @staticmethod @@ -540,15 +540,15 @@ class _UserComponentType(type): ) ) - if not hasattr(iter_cls, '__next__'): + if not hasattr(iter_cls, "__next__"): raise bt2._IncompleteUserClass( "cannot create component class '{}': message iterator class is missing a __next__() method".format( cls.__name__ ) ) - if hasattr(iter_cls, '_user_can_seek_ns_from_origin') and not hasattr( - iter_cls, '_user_seek_ns_from_origin' + if hasattr(iter_cls, "_user_can_seek_ns_from_origin") and not hasattr( + iter_cls, "_user_seek_ns_from_origin" ): raise bt2._IncompleteUserClass( "cannot create component class '{}': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin".format( @@ -556,8 +556,8 @@ class _UserComponentType(type): ) ) - if hasattr(iter_cls, '_user_can_seek_beginning') and not hasattr( - iter_cls, '_user_seek_beginning' + if hasattr(iter_cls, "_user_can_seek_beginning") and not hasattr( + iter_cls, "_user_seek_beginning" ): raise bt2._IncompleteUserClass( "cannot create component class '{}': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning".format( @@ -649,7 +649,7 @@ class _UserComponentType(type): return self._bt_as_component_class_ptr(self._bt_cc_ptr) def __del__(cls): - if hasattr(cls, '_bt_cc_ptr'): + if hasattr(cls, "_bt_cc_ptr"): cc_ptr = cls._bt_as_component_class_ptr(cls._bt_cc_ptr) native_bt.component_class_put_ref(cc_ptr) native_bt.bt2_unregister_cc_ptr_to_py_cls(cc_ptr) @@ -753,7 +753,7 @@ class _UserComponent(metaclass=_UserComponentType): tc_ptr = native_bt.trace_class_create(ptr) if tc_ptr is None: - raise bt2._MemoryError('could not create trace class') + raise bt2._MemoryError("could not create trace class") tc = bt2_trace_class._TraceClass._create_from_ptr(tc_ptr) tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id @@ -778,7 +778,7 @@ class _UserComponent(metaclass=_UserComponentType): cc_ptr = native_bt.clock_class_create(ptr) if cc_ptr is None: - raise bt2._MemoryError('could not create clock class') + raise bt2._MemoryError("could not create clock class") cc = bt2_clock_class._ClockClass._create_from_ptr(cc_ptr) @@ -836,7 +836,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst): if name in self._output_ports: raise ValueError( - 'source component `{}` already contains an output port named `{}`'.format( + "source component `{}` already contains an output port named `{}`".format( self.name, name ) ) @@ -844,7 +844,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst): fn = native_bt.self_component_source_add_output_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) utils._handle_func_status( - comp_status, 'cannot add output port to source component object' + comp_status, "cannot add output port to source component object" ) assert self_port_ptr is not None return bt2_port._UserComponentOutputPort._create_from_ptr_and_get_ref( @@ -894,7 +894,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): if name in self._output_ports: raise ValueError( - 'filter component `{}` already contains an output port named `{}`'.format( + "filter component `{}` already contains an output port named `{}`".format( self.name, name ) ) @@ -902,7 +902,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): fn = native_bt.self_component_filter_add_output_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) utils._handle_func_status( - comp_status, 'cannot add output port to filter component object' + comp_status, "cannot add output port to filter component object" ) assert self_port_ptr return bt2_port._UserComponentOutputPort._create_from_ptr_and_get_ref( @@ -914,7 +914,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): if name in self._input_ports: raise ValueError( - 'filter component `{}` already contains an input port named `{}`'.format( + "filter component `{}` already contains an input port named `{}`".format( self.name, name ) ) @@ -922,7 +922,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): fn = native_bt.self_component_filter_add_input_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) utils._handle_func_status( - comp_status, 'cannot add input port to filter component object' + comp_status, "cannot add input port to filter component object" ) assert self_port_ptr return bt2_port._UserComponentInputPort._create_from_ptr_and_get_ref( @@ -964,7 +964,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): if name in self._input_ports: raise ValueError( - 'sink component `{}` already contains an input port named `{}`'.format( + "sink component `{}` already contains an input port named `{}`".format( self.name, name ) ) @@ -972,7 +972,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): fn = native_bt.self_component_sink_add_input_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) utils._handle_func_status( - comp_status, 'cannot add input port to sink component object' + comp_status, "cannot add input port to sink component object" ) assert self_port_ptr return bt2_port._UserComponentInputPort._create_from_ptr_and_get_ref( @@ -983,7 +983,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): utils._check_type(input_port, bt2_port._UserComponentInputPort) if not input_port.is_connected: - raise ValueError('input port is not connected') + raise ValueError("input port is not connected") ( status, @@ -991,7 +991,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): ) = native_bt.bt2_message_iterator_create_from_sink_component( self._bt_ptr, input_port._ptr ) - utils._handle_func_status(status, 'cannot create message iterator object') + utils._handle_func_status(status, "cannot create message iterator object") assert msg_iter_ptr is not None return bt2_message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr) diff --git a/src/bindings/python/bt2/bt2/component_descriptor.py b/src/bindings/python/bt2/bt2/component_descriptor.py index b4557a05..c09c98ef 100644 --- a/src/bindings/python/bt2/bt2/component_descriptor.py +++ b/src/bindings/python/bt2/bt2/component_descriptor.py @@ -53,7 +53,7 @@ class ComponentDescriptor: base_cc_ptr = component_class._bt_component_class_ptr() if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr): - raise ValueError('cannot pass a Python object to a non-Python component') + raise ValueError("cannot pass a Python object to a non-Python component") self._comp_cls = component_class self._params = bt2.create_value(params) diff --git a/src/bindings/python/bt2/bt2/error.py b/src/bindings/python/bt2/bt2/error.py index a0673451..e07a3f90 100644 --- a/src/bindings/python/bt2/bt2/error.py +++ b/src/bindings/python/bt2/bt2/error.py @@ -13,9 +13,9 @@ class ComponentClassType: _COMPONENT_CLASS_TYPE_TO_STR = { - native_bt.COMPONENT_CLASS_TYPE_SOURCE: 'source', - native_bt.COMPONENT_CLASS_TYPE_FILTER: 'filter', - native_bt.COMPONENT_CLASS_TYPE_SINK: 'sink', + native_bt.COMPONENT_CLASS_TYPE_SOURCE: "source", + native_bt.COMPONENT_CLASS_TYPE_FILTER: "filter", + native_bt.COMPONENT_CLASS_TYPE_SINK: "sink", } @@ -174,7 +174,7 @@ class _Error(Exception, abc.Sequence): assert self._ptr is not None self._msg = msg - self._str = msg + '\n' + native_bt.bt2_format_bt_error(self._ptr) + self._str = msg + "\n" + native_bt.bt2_format_bt_error(self._ptr) # Read everything we might need from the error pointer, so we don't # depend on it. It's possible for the user to keep an Error object diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index 8af7b769..40ce52c5 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -83,7 +83,7 @@ class _Field(_FieldConst): class _BitArrayFieldConst(_FieldConst): - _NAME = 'Const bit array' + _NAME = "Const bit array" @property def value_as_integer(self): @@ -106,7 +106,7 @@ class _BitArrayFieldConst(_FieldConst): class _BitArrayField(_BitArrayFieldConst, _Field): - _NAME = 'Bit array' + _NAME = "Bit array" def _value_as_integer(self, value): utils._check_uint64(value) @@ -149,7 +149,7 @@ class _NumericFieldConst(_FieldConst): def __lt__(self, other): if not isinstance(other, numbers.Number): raise TypeError( - 'unorderable types: {}() < {}()'.format( + "unorderable types: {}() < {}()".format( self.__class__.__name__, other.__class__.__name__ ) ) @@ -230,7 +230,7 @@ class _NumericField(_NumericFieldConst, _Field): def __hash__(self): # Non const field are not hashable as their value may be modified # without changing the underlying Python object. - raise TypeError('unhashable type: \'{}\''.format(self._NAME)) + raise TypeError("unhashable type: '{}'".format(self._NAME)) class _IntegralFieldConst(_NumericFieldConst, numbers.Integral): @@ -273,7 +273,7 @@ class _IntegralField(_IntegralFieldConst, _NumericField): class _BoolFieldConst(_IntegralFieldConst, _FieldConst): - _NAME = 'Const boolean' + _NAME = "Const boolean" def __bool__(self): return self._value @@ -298,7 +298,7 @@ class _BoolFieldConst(_IntegralFieldConst, _FieldConst): class _BoolField(_BoolFieldConst, _IntegralField, _Field): - _NAME = 'Boolean' + _NAME = "Boolean" def _set_value(self, value): value = self._value_to_bool(value) @@ -322,12 +322,12 @@ class _IntegerField(_IntegerFieldConst, _IntegralField, _Field): class _UnsignedIntegerFieldConst(_IntegerFieldConst, _FieldConst): - _NAME = 'Const unsigned integer' + _NAME = "Const unsigned integer" @classmethod def _value_to_int(cls, value): if not isinstance(value, numbers.Integral): - raise TypeError('expecting an integral number object') + raise TypeError("expecting an integral number object") return int(value) @@ -337,7 +337,7 @@ class _UnsignedIntegerFieldConst(_IntegerFieldConst, _FieldConst): class _UnsignedIntegerField(_UnsignedIntegerFieldConst, _IntegerField, _Field): - _NAME = 'Unsigned integer' + _NAME = "Unsigned integer" def _set_value(self, value): value = self._value_to_int(value) @@ -358,12 +358,12 @@ class _UnsignedIntegerField(_UnsignedIntegerFieldConst, _IntegerField, _Field): class _SignedIntegerFieldConst(_IntegerFieldConst, _FieldConst): - _NAME = 'Const signed integer' + _NAME = "Const signed integer" @classmethod def _value_to_int(cls, value): if not isinstance(value, numbers.Integral): - raise TypeError('expecting an integral number object') + raise TypeError("expecting an integral number object") return int(value) @@ -373,7 +373,7 @@ class _SignedIntegerFieldConst(_IntegerFieldConst, _FieldConst): class _SignedIntegerField(_SignedIntegerFieldConst, _IntegerField, _Field): - _NAME = 'Signed integer' + _NAME = "Signed integer" def _set_value(self, value): value = self._value_to_int(value) @@ -394,7 +394,7 @@ class _SignedIntegerField(_SignedIntegerFieldConst, _IntegerField, _Field): class _RealFieldConst(_NumericFieldConst, numbers.Real): - _NAME = 'Const real' + _NAME = "Const real" @classmethod def _value_to_float(cls, value): @@ -405,7 +405,7 @@ class _RealFieldConst(_NumericFieldConst, numbers.Real): class _SinglePrecisionRealFieldConst(_RealFieldConst): - _NAME = 'Const single-precision real' + _NAME = "Const single-precision real" @property def _value(self): @@ -413,7 +413,7 @@ class _SinglePrecisionRealFieldConst(_RealFieldConst): class _DoublePrecisionRealFieldConst(_RealFieldConst): - _NAME = 'Const double-precision real' + _NAME = "Const double-precision real" @property def _value(self): @@ -421,11 +421,11 @@ class _DoublePrecisionRealFieldConst(_RealFieldConst): class _RealField(_RealFieldConst, _NumericField): - _NAME = 'Real' + _NAME = "Real" class _SinglePrecisionRealField(_SinglePrecisionRealFieldConst, _RealField): - _NAME = 'Single-precision real' + _NAME = "Single-precision real" def _set_value(self, value): value = self._value_to_float(value) @@ -435,7 +435,7 @@ class _SinglePrecisionRealField(_SinglePrecisionRealFieldConst, _RealField): class _DoublePrecisionRealField(_DoublePrecisionRealFieldConst, _RealField): - _NAME = 'Double-precision real' + _NAME = "Double-precision real" def _set_value(self, value): value = self._value_to_float(value) @@ -446,7 +446,7 @@ class _DoublePrecisionRealField(_DoublePrecisionRealFieldConst, _RealField): class _EnumerationFieldConst(_IntegerFieldConst): def _repr(self): - return '{} ({})'.format(self._value, ', '.join(self.labels)) + return "{} ({})".format(self._value, ", ".join(self.labels)) @property def labels(self): @@ -464,7 +464,7 @@ class _EnumerationField(_EnumerationFieldConst, _IntegerField): class _UnsignedEnumerationFieldConst( _EnumerationFieldConst, _UnsignedIntegerFieldConst ): - _NAME = 'Const unsigned Enumeration' + _NAME = "Const unsigned Enumeration" _get_mapping_labels = staticmethod( native_bt.field_enumeration_unsigned_get_mapping_labels ) @@ -473,11 +473,11 @@ class _UnsignedEnumerationFieldConst( class _UnsignedEnumerationField( _UnsignedEnumerationFieldConst, _EnumerationField, _UnsignedIntegerField ): - _NAME = 'Unsigned enumeration' + _NAME = "Unsigned enumeration" class _SignedEnumerationFieldConst(_EnumerationFieldConst, _SignedIntegerFieldConst): - _NAME = 'Const signed Enumeration' + _NAME = "Const signed Enumeration" _get_mapping_labels = staticmethod( native_bt.field_enumeration_signed_get_mapping_labels ) @@ -486,12 +486,12 @@ class _SignedEnumerationFieldConst(_EnumerationFieldConst, _SignedIntegerFieldCo class _SignedEnumerationField( _SignedEnumerationFieldConst, _EnumerationField, _SignedIntegerField ): - _NAME = 'Signed enumeration' + _NAME = "Signed enumeration" @functools.total_ordering class _StringFieldConst(_FieldConst): - _NAME = 'Const string' + _NAME = "Const string" @classmethod def _value_to_str(cls, value): @@ -536,7 +536,7 @@ class _StringFieldConst(_FieldConst): class _StringField(_StringFieldConst, _Field): - _NAME = 'String' + _NAME = "String" def _set_value(self, value): value = self._value_to_str(value) @@ -555,7 +555,7 @@ class _StringField(_StringFieldConst, _Field): def __hash__(self): # Non const field are not hashable as their value may be modified # without changing the underlying Python object. - raise TypeError('unhashable type: \'{}\''.format(self._NAME)) + raise TypeError("unhashable type: '{}'".format(self._NAME)) class _ContainerFieldConst(_FieldConst): @@ -575,7 +575,7 @@ class _ContainerFieldConst(_FieldConst): def __setitem__(self, index, value): raise TypeError( - '\'{}\' object does not support item assignment'.format(self.__class__) + "'{}' object does not support item assignment".format(self.__class__) ) @@ -584,7 +584,7 @@ class _ContainerField(_ContainerFieldConst, _Field): class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping): - _NAME = 'Const structure' + _NAME = "Const structure" _borrow_member_field_ptr_by_index = staticmethod( native_bt.field_structure_borrow_member_field_by_index_const ) @@ -617,8 +617,8 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping): return True def _repr(self): - items = ['{}: {}'.format(repr(k), repr(v)) for k, v in self.items()] - return '{{{}}}'.format(', '.join(items)) + items = ["{}: {}".format(repr(k), repr(v)) for k, v in self.items()] + return "{{{}}}".format(", ".join(items)) def __getitem__(self, key): utils._check_str(key) @@ -646,7 +646,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping): class _StructureField( _StructureFieldConst, _ContainerField, collections.abc.MutableMapping ): - _NAME = 'Structure' + _NAME = "Structure" _borrow_member_field_ptr_by_index = staticmethod( native_bt.field_structure_borrow_member_field_by_index ) @@ -673,7 +673,7 @@ class _StructureField( class _OptionFieldConst(_FieldConst): - _NAME = 'Const option' + _NAME = "Const option" _borrow_field_ptr = staticmethod(native_bt.field_option_borrow_field_const) @property @@ -705,7 +705,7 @@ class _OptionFieldConst(_FieldConst): class _OptionField(_OptionFieldConst, _Field): - _NAME = 'Option' + _NAME = "Option" _borrow_field_ptr = staticmethod(native_bt.field_option_borrow_field) def _has_field(self, value): @@ -724,7 +724,7 @@ class _OptionField(_OptionFieldConst, _Field): class _VariantFieldConst(_ContainerFieldConst, _FieldConst): - _NAME = 'Const variant' + _NAME = "Const variant" _borrow_selected_option_field_ptr = staticmethod( native_bt.field_variant_borrow_selected_option_field_const ) @@ -761,14 +761,14 @@ class _VariantFieldConst(_ContainerFieldConst, _FieldConst): class _VariantField(_VariantFieldConst, _ContainerField, _Field): - _NAME = 'Variant' + _NAME = "Variant" _borrow_selected_option_field_ptr = staticmethod( native_bt.field_variant_borrow_selected_option_field ) def _selected_option_index(self, index): if index < 0 or index >= len(self): - raise IndexError('{} field object index is out of range'.format(self._NAME)) + raise IndexError("{} field object index is out of range".format(self._NAME)) native_bt.field_variant_select_option_by_index(self._ptr, index) @@ -803,7 +803,7 @@ class _ArrayFieldConst(_ContainerFieldConst, _FieldConst, collections.abc.Sequen index = int(index) if index < 0 or index >= len(self): - raise IndexError('{} field object index is out of range'.format(self._NAME)) + raise IndexError("{} field object index is out of range".format(self._NAME)) field_ptr = self._borrow_element_field_ptr_by_index(self._ptr, index) assert field_ptr @@ -829,7 +829,7 @@ class _ArrayFieldConst(_ContainerFieldConst, _FieldConst, collections.abc.Sequen return True def _repr(self): - return '[{}]'.format(', '.join([repr(v) for v in self])) + return "[{}]".format(", ".join([repr(v) for v in self])) class _ArrayField( @@ -844,7 +844,7 @@ class _ArrayField( field = self[index] if not isinstance(field, (_NumericField, _StringField)): - raise TypeError('can only set the value of a number or string field') + raise TypeError("can only set the value of a number or string field") # the field's property does the appropriate conversion or raises # the appropriate exception @@ -852,19 +852,19 @@ class _ArrayField( class _StaticArrayFieldConst(_ArrayFieldConst, _FieldConst): - _NAME = 'Const static array' + _NAME = "Const static array" def _count(self): return native_bt.field_array_get_length(self._ptr) class _StaticArrayField(_StaticArrayFieldConst, _ArrayField, _Field): - _NAME = 'Static array' + _NAME = "Static array" def _set_value(self, values): if len(self) != len(values): raise ValueError( - 'expected length of value ({}) and array field ({}) to match'.format( + "expected length of value ({}) and array field ({}) to match".format( len(values), len(self) ) ) @@ -877,14 +877,14 @@ class _StaticArrayField(_StaticArrayFieldConst, _ArrayField, _Field): class _DynamicArrayFieldConst(_ArrayFieldConst, _FieldConst): - _NAME = 'Const dynamic array' + _NAME = "Const dynamic array" def _count(self): return self.length class _DynamicArrayField(_DynamicArrayFieldConst, _ArrayField, _Field): - _NAME = 'Dynamic array' + _NAME = "Dynamic array" def _set_length(self, length): utils._check_uint64(length) diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index 0d0934a8..eed50140 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -57,7 +57,7 @@ class _FieldClassConst(object._SharedObject): def _check_create_status(self, ptr): if ptr is None: raise bt2._MemoryError( - 'cannot create {} field class object'.format(self._NAME.lower()) + "cannot create {} field class object".format(self._NAME.lower()) ) @property @@ -84,15 +84,15 @@ class _FieldClass(_FieldClassConst): class _BoolFieldClassConst(_FieldClassConst): - _NAME = 'Const boolean' + _NAME = "Const boolean" class _BoolFieldClass(_BoolFieldClassConst, _FieldClass): - _NAME = 'Boolean' + _NAME = "Boolean" class _BitArrayFieldClassConst(_FieldClassConst): - _NAME = 'Const bit array' + _NAME = "Const bit array" @property def length(self): @@ -102,7 +102,7 @@ class _BitArrayFieldClassConst(_FieldClassConst): class _BitArrayFieldClass(_BitArrayFieldClassConst, _FieldClass): - _NAME = 'Bit array' + _NAME = "Bit array" class _IntegerFieldClassConst(_FieldClassConst): @@ -144,23 +144,23 @@ class _IntegerFieldClass(_FieldClass, _IntegerFieldClassConst): class _UnsignedIntegerFieldClassConst(_IntegerFieldClassConst, _FieldClassConst): - _NAME = 'Const unsigned integer' + _NAME = "Const unsigned integer" class _UnsignedIntegerFieldClass( _UnsignedIntegerFieldClassConst, _IntegerFieldClass, _FieldClass ): - _NAME = 'Unsigned integer' + _NAME = "Unsigned integer" class _SignedIntegerFieldClassConst(_IntegerFieldClassConst, _FieldClassConst): - _NAME = 'Const signed integer' + _NAME = "Const signed integer" class _SignedIntegerFieldClass( _SignedIntegerFieldClassConst, _IntegerFieldClass, _FieldClass ): - _NAME = 'Signed integer' + _NAME = "Signed integer" class _RealFieldClassConst(_FieldClassConst): @@ -168,11 +168,11 @@ class _RealFieldClassConst(_FieldClassConst): class _SinglePrecisionRealFieldClassConst(_RealFieldClassConst): - _NAME = 'Const single-precision real' + _NAME = "Const single-precision real" class _DoublePrecisionRealFieldClassConst(_RealFieldClassConst): - _NAME = 'Const double-precision real' + _NAME = "Const double-precision real" class _RealFieldClass(_FieldClass, _RealFieldClassConst): @@ -180,11 +180,11 @@ class _RealFieldClass(_FieldClass, _RealFieldClassConst): class _SinglePrecisionRealFieldClass(_RealFieldClass): - _NAME = 'Single-precision real' + _NAME = "Single-precision real" class _DoublePrecisionRealFieldClass(_RealFieldClass): - _NAME = 'Double-precision real' + _NAME = "Double-precision real" # an enumeration field class mapping does not have a reference count, so @@ -240,7 +240,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi status, labels = self._get_mapping_labels_for_value(self._ptr, value) utils._handle_func_status( - status, 'cannot get mapping labels for value {}'.format(value) + status, "cannot get mapping labels for value {}".format(value) ) return [self[label] for label in labels] @@ -269,7 +269,7 @@ class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): status = self._add_mapping(self._ptr, label, ranges._ptr) utils._handle_func_status( - status, 'cannot add mapping to enumeration field class object' + status, "cannot add mapping to enumeration field class object" ) def __iadd__(self, mappings): @@ -282,7 +282,7 @@ class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): class _UnsignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _UnsignedIntegerFieldClassConst ): - _NAME = 'Const unsigned enumeration' + _NAME = "Const unsigned enumeration" _borrow_mapping_ptr_by_label = staticmethod( native_bt.field_class_enumeration_unsigned_borrow_mapping_by_label_const ) @@ -301,7 +301,7 @@ class _UnsignedEnumerationFieldClass( _EnumerationFieldClass, _UnsignedIntegerFieldClass, ): - _NAME = 'Unsigned enumeration' + _NAME = "Unsigned enumeration" _range_set_pycls = bt2_integer_range_set.UnsignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_unsigned_add_mapping) @@ -309,7 +309,7 @@ class _UnsignedEnumerationFieldClass( class _SignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _SignedIntegerFieldClassConst ): - _NAME = 'Const signed enumeration' + _NAME = "Const signed enumeration" _borrow_mapping_ptr_by_label = staticmethod( native_bt.field_class_enumeration_signed_borrow_mapping_by_label_const ) @@ -326,17 +326,17 @@ class _SignedEnumerationFieldClassConst( class _SignedEnumerationFieldClass( _SignedEnumerationFieldClassConst, _EnumerationFieldClass, _SignedIntegerFieldClass ): - _NAME = 'Signed enumeration' + _NAME = "Signed enumeration" _range_set_pycls = bt2_integer_range_set.SignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_signed_add_mapping) class _StringFieldClassConst(_FieldClassConst): - _NAME = 'Const string' + _NAME = "Const string" class _StringFieldClass(_StringFieldClassConst, _FieldClass): - _NAME = 'String' + _NAME = "String" class _StructureFieldClassMemberConst: @@ -403,7 +403,7 @@ class _StructureFieldClassMember(_StructureFieldClassMemberConst): class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping): - _NAME = 'Const structure' + _NAME = "Const structure" _borrow_member_ptr_by_index = staticmethod( native_bt.field_class_structure_borrow_member_by_index_const ) @@ -450,7 +450,7 @@ class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping): class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): - _NAME = 'Structure' + _NAME = "Structure" _borrow_member_by_index = staticmethod( native_bt.field_class_structure_borrow_member_by_index ) @@ -476,7 +476,7 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): self._ptr, name, field_class._ptr ) utils._handle_func_status( - status, 'cannot append member to structure field class object' + status, "cannot append member to structure field class object" ) if user_attributes is not None: @@ -490,7 +490,7 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): class _OptionFieldClassConst(_FieldClassConst): - _NAME = 'Const option' + _NAME = "Const option" _create_field_class_from_ptr_and_get_ref = staticmethod( _create_field_class_from_const_ptr_and_get_ref ) @@ -505,7 +505,7 @@ class _OptionFieldClassConst(_FieldClassConst): class _OptionWithSelectorFieldClassConst(_OptionFieldClassConst): - _NAME = 'Const option (with selector)' + _NAME = "Const option (with selector)" @property def selector_field_path(self): @@ -519,7 +519,7 @@ class _OptionWithSelectorFieldClassConst(_OptionFieldClassConst): class _OptionWithBoolSelectorFieldClassConst(_OptionWithSelectorFieldClassConst): - _NAME = 'Const option (with boolean selector)' + _NAME = "Const option (with boolean selector)" @property def selector_is_reversed(self): @@ -531,7 +531,7 @@ class _OptionWithBoolSelectorFieldClassConst(_OptionWithSelectorFieldClassConst) class _OptionWithIntegerSelectorFieldClassConst(_OptionWithSelectorFieldClassConst): - _NAME = 'Const option (with integer selector)' + _NAME = "Const option (with integer selector)" @property def ranges(self): @@ -543,7 +543,7 @@ class _OptionWithIntegerSelectorFieldClassConst(_OptionWithSelectorFieldClassCon class _OptionWithUnsignedIntegerSelectorFieldClassConst( _OptionWithIntegerSelectorFieldClassConst ): - _NAME = 'Const option (with unsigned integer selector)' + _NAME = "Const option (with unsigned integer selector)" _range_set_pycls = bt2_integer_range_set._UnsignedIntegerRangeSetConst _borrow_selector_ranges_ptr = staticmethod( native_bt.field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const @@ -553,7 +553,7 @@ class _OptionWithUnsignedIntegerSelectorFieldClassConst( class _OptionWithSignedIntegerSelectorFieldClassConst( _OptionWithIntegerSelectorFieldClassConst ): - _NAME = 'Const option (with signed integer selector)' + _NAME = "Const option (with signed integer selector)" _range_set_pycls = bt2_integer_range_set._SignedIntegerRangeSetConst _borrow_selector_ranges_ptr = staticmethod( native_bt.field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const @@ -561,7 +561,7 @@ class _OptionWithSignedIntegerSelectorFieldClassConst( class _OptionFieldClass(_OptionFieldClassConst, _FieldClass): - _NAME = 'Option' + _NAME = "Option" _borrow_field_class_ptr = staticmethod( native_bt.field_class_option_borrow_field_class ) @@ -573,13 +573,13 @@ class _OptionFieldClass(_OptionFieldClassConst, _FieldClass): class _OptionWithSelectorFieldClass( _OptionWithSelectorFieldClassConst, _OptionFieldClass ): - _NAME = 'Option (with selector)' + _NAME = "Option (with selector)" class _OptionWithBoolSelectorFieldClass( _OptionWithBoolSelectorFieldClassConst, _OptionWithSelectorFieldClass ): - _NAME = 'Option (with boolean selector)' + _NAME = "Option (with boolean selector)" def _selector_is_reversed(self, selector_is_reversed): utils._check_bool(selector_is_reversed) @@ -593,21 +593,21 @@ class _OptionWithBoolSelectorFieldClass( class _OptionWithIntegerSelectorFieldClass( _OptionWithIntegerSelectorFieldClassConst, _OptionWithSelectorFieldClass ): - _NAME = 'Option (with integer selector)' + _NAME = "Option (with integer selector)" class _OptionWithUnsignedIntegerSelectorFieldClass( _OptionWithUnsignedIntegerSelectorFieldClassConst, _OptionWithIntegerSelectorFieldClass, ): - _NAME = 'Option (with unsigned integer selector)' + _NAME = "Option (with unsigned integer selector)" class _OptionWithSignedIntegerSelectorFieldClass( _OptionWithSignedIntegerSelectorFieldClassConst, _OptionWithIntegerSelectorFieldClass, ): - _NAME = 'Option (with signed integer selector)' + _NAME = "Option (with signed integer selector)" class _VariantFieldClassOptionConst: @@ -728,7 +728,7 @@ class _VariantFieldClassWithUnsignedIntegerSelectorOption( class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping): - _NAME = 'Const variant' + _NAME = "Const variant" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_borrow_option_by_name_const ) @@ -781,7 +781,7 @@ class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping): class _VariantFieldClass(_VariantFieldClassConst, _FieldClass, collections.abc.Mapping): - _NAME = 'Variant' + _NAME = "Variant" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_borrow_option_by_name ) @@ -792,13 +792,13 @@ class _VariantFieldClass(_VariantFieldClassConst, _FieldClass, collections.abc.M class _VariantFieldClassWithoutSelectorConst(_VariantFieldClassConst): - _NAME = 'Const variant (without selector)' + _NAME = "Const variant (without selector)" class _VariantFieldClassWithoutSelector( _VariantFieldClassWithoutSelectorConst, _VariantFieldClass ): - _NAME = 'Variant (without selector)' + _NAME = "Variant (without selector)" def append_option(self, name, field_class, user_attributes=None): utils._check_str(name) @@ -817,7 +817,7 @@ class _VariantFieldClassWithoutSelector( self._ptr, name, field_class._ptr ) utils._handle_func_status( - status, 'cannot append option to variant field class object' + status, "cannot append option to variant field class object" ) if user_attributes is not None: @@ -831,7 +831,7 @@ class _VariantFieldClassWithoutSelector( class _VariantFieldClassWithIntegerSelectorConst(_VariantFieldClassConst): - _NAME = 'Const variant (with selector)' + _NAME = "Const variant (with selector)" @property def selector_field_path(self): @@ -848,7 +848,7 @@ class _VariantFieldClassWithIntegerSelectorConst(_VariantFieldClassConst): class _VariantFieldClassWithIntegerSelector( _VariantFieldClassWithIntegerSelectorConst, _VariantFieldClass ): - _NAME = 'Variant (with selector)' + _NAME = "Variant (with selector)" def append_option(self, name, field_class, ranges, user_attributes=None): utils._check_str(name) @@ -859,7 +859,7 @@ class _VariantFieldClassWithIntegerSelector( raise ValueError("duplicate option name '{}'".format(name)) if len(ranges) == 0: - raise ValueError('range set is empty') + raise ValueError("range set is empty") user_attributes_value = None @@ -871,7 +871,7 @@ class _VariantFieldClassWithIntegerSelector( status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr) utils._handle_func_status( - status, 'cannot append option to variant field class object' + status, "cannot append option to variant field class object" ) if user_attributes is not None: @@ -887,7 +887,7 @@ class _VariantFieldClassWithIntegerSelector( class _VariantFieldClassWithUnsignedIntegerSelectorConst( _VariantFieldClassWithIntegerSelectorConst ): - _NAME = 'Const variant (with unsigned integer selector)' + _NAME = "Const variant (with unsigned integer selector)" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const ) @@ -902,7 +902,7 @@ class _VariantFieldClassWithUnsignedIntegerSelector( _VariantFieldClassWithUnsignedIntegerSelectorConst, _VariantFieldClassWithIntegerSelector, ): - _NAME = 'Variant (with unsigned integer selector)' + _NAME = "Variant (with unsigned integer selector)" _variant_option_pycls = _VariantFieldClassWithUnsignedIntegerSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) _append_option = staticmethod( @@ -913,7 +913,7 @@ class _VariantFieldClassWithUnsignedIntegerSelector( class _VariantFieldClassWithSignedIntegerSelectorConst( _VariantFieldClassWithIntegerSelectorConst ): - _NAME = 'Const variant (with signed integer selector)' + _NAME = "Const variant (with signed integer selector)" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const ) @@ -928,7 +928,7 @@ class _VariantFieldClassWithSignedIntegerSelector( _VariantFieldClassWithSignedIntegerSelectorConst, _VariantFieldClassWithIntegerSelector, ): - _NAME = 'Variant (with signed integer selector)' + _NAME = "Variant (with signed integer selector)" _variant_option_pycls = _VariantFieldClassWithSignedIntegerSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) _append_option = staticmethod( @@ -960,7 +960,7 @@ class _ArrayFieldClass(_ArrayFieldClassConst, _FieldClass): class _StaticArrayFieldClassConst(_ArrayFieldClassConst): - _NAME = 'Const static array' + _NAME = "Const static array" @property def length(self): @@ -968,15 +968,15 @@ class _StaticArrayFieldClassConst(_ArrayFieldClassConst): class _StaticArrayFieldClass(_StaticArrayFieldClassConst, _ArrayFieldClass): - _NAME = 'Static array' + _NAME = "Static array" class _DynamicArrayFieldClassConst(_ArrayFieldClassConst): - _NAME = 'Const dynamic array' + _NAME = "Const dynamic array" class _DynamicArrayWithLengthFieldFieldClassConst(_DynamicArrayFieldClassConst): - _NAME = 'Const dynamic array (with length field)' + _NAME = "Const dynamic array (with length field)" @property def length_field_path(self): @@ -990,13 +990,13 @@ class _DynamicArrayWithLengthFieldFieldClassConst(_DynamicArrayFieldClassConst): class _DynamicArrayFieldClass(_DynamicArrayFieldClassConst, _ArrayFieldClass): - _NAME = 'Dynamic array' + _NAME = "Dynamic array" class _DynamicArrayWithLengthFieldFieldClass( _DynamicArrayWithLengthFieldFieldClassConst, _DynamicArrayFieldClass ): - _NAME = 'Dynamic array (with length field)' + _NAME = "Dynamic array (with length field)" _FIELD_CLASS_TYPE_TO_CONST_OBJ = { diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index 78fca79f..ed99ef07 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -30,12 +30,12 @@ class Graph(object._SharedObject): utils._check_uint64(mip_version) if mip_version > bt2.get_maximal_mip_version(): - raise ValueError('unknown MIP version {}'.format(mip_version)) + raise ValueError("unknown MIP version {}".format(mip_version)) ptr = native_bt.graph_create(mip_version) if ptr is None: - raise bt2._MemoryError('cannot create graph object') + raise bt2._MemoryError("cannot create graph object") super().__init__(ptr) @@ -87,7 +87,7 @@ class Graph(object._SharedObject): base_cc_ptr = component_class._bt_component_class_ptr() if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr): - raise ValueError('cannot pass a Python object to a non-Python component') + raise ValueError("cannot pass a Python object to a non-Python component") if params is not None and not isinstance(params, (dict, bt2.MapValue)): raise TypeError("'params' parameter is not a 'dict' or a 'bt2.MapValue'.") @@ -99,7 +99,7 @@ class Graph(object._SharedObject): status, comp_ptr = add_fn( self._ptr, cc_ptr, name, params_ptr, obj, logging_level ) - utils._handle_func_status(status, 'cannot add component to graph') + utils._handle_func_status(status, "cannot add component to graph") assert comp_ptr return bt2_component._create_component_from_const_ptr_and_get_ref( comp_ptr, cc_type @@ -111,7 +111,7 @@ class Graph(object._SharedObject): status, conn_ptr = native_bt.graph_connect_ports( self._ptr, upstream_port._ptr, downstream_port._ptr ) - utils._handle_func_status(status, 'cannot connect component ports within graph') + utils._handle_func_status(status, "cannot connect component ports within graph") assert conn_ptr return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr) @@ -126,18 +126,18 @@ class Graph(object._SharedObject): listener_ids = fn(self._ptr, listener_from_native) if listener_ids is None: - raise bt2._Error('cannot add listener to graph object') + raise bt2._Error("cannot add listener to graph object") # keep the partial's reference self._listener_partials.append(listener_from_native) def run_once(self): status = native_bt.graph_run_once(self._ptr) - utils._handle_func_status(status, 'graph object could not run once') + utils._handle_func_status(status, "graph object could not run once") def run(self): status = native_bt.graph_run(self._ptr) - utils._handle_func_status(status, 'graph object stopped running') + utils._handle_func_status(status, "graph object stopped running") def add_interrupter(self, interrupter): utils._check_type(interrupter, bt2_interrupter.Interrupter) diff --git a/src/bindings/python/bt2/bt2/integer_range_set.py b/src/bindings/python/bt2/bt2/integer_range_set.py index c1bddae3..79006f33 100644 --- a/src/bindings/python/bt2/bt2/integer_range_set.py +++ b/src/bindings/python/bt2/bt2/integer_range_set.py @@ -110,7 +110,7 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet): ptr = self._create_range_set() if ptr is None: - raise bt2._MemoryError('cannot create range set object') + raise bt2._MemoryError("cannot create range set object") super().__init__(ptr) @@ -128,7 +128,7 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet): rg = self._range_pycls(rg[0], rg[1]) status = self._add_range(self._ptr, rg.lower, rg.upper) - utils._handle_func_status(status, 'cannot add range to range set object') + utils._handle_func_status(status, "cannot add range to range set object") def discard(self, rg): raise NotImplementedError diff --git a/src/bindings/python/bt2/bt2/interrupter.py b/src/bindings/python/bt2/bt2/interrupter.py index 539f9990..39c22883 100644 --- a/src/bindings/python/bt2/bt2/interrupter.py +++ b/src/bindings/python/bt2/bt2/interrupter.py @@ -14,7 +14,7 @@ class Interrupter(object._SharedObject): ptr = native_bt.interrupter_create() if ptr is None: - raise bt2._MemoryError('cannot create interrupter object') + raise bt2._MemoryError("cannot create interrupter object") super().__init__(ptr) diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index 5f5b8656..5039d923 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -22,7 +22,7 @@ class _MessageConst(object._SharedObject): def _check_has_default_clock_class(clock_class): if clock_class is None: raise ValueError( - 'cannot get default clock snapshot: stream class has no default clock class' + "cannot get default clock snapshot: stream class has no default clock class" ) @@ -212,7 +212,7 @@ class _DiscardedMessageConst(_MessageConst, _MessageWithDefaultClockSnapshot): def _check_has_default_clock_snapshots(self): if not self._has_default_clock_snapshots: raise ValueError( - 'cannot get default clock snapshot: such a message has no clock snapshots for this stream class' + "cannot get default clock snapshot: such a message has no clock snapshots for this stream class" ) @property @@ -235,7 +235,7 @@ class _DiscardedMessage(_DiscardedMessageConst, _Message): utils._check_uint64(count) if count == 0: - raise ValueError('discarded {} count is 0'.format(self._item_name)) + raise ValueError("discarded {} count is 0".format(self._item_name)) self._set_count(self._ptr, count) @@ -262,7 +262,7 @@ class _DiscardedEventsMessageConst(_DiscardedMessageConst): class _DiscardedEventsMessage(_DiscardedEventsMessageConst, _DiscardedMessage): _borrow_stream_ptr = staticmethod(native_bt.message_discarded_events_borrow_stream) _set_count = staticmethod(native_bt.message_discarded_events_set_count) - _item_name = 'event' + _item_name = "event" class _DiscardedPacketsMessageConst(_DiscardedMessageConst): @@ -285,7 +285,7 @@ class _DiscardedPacketsMessageConst(_DiscardedMessageConst): class _DiscardedPacketsMessage(_DiscardedPacketsMessageConst, _DiscardedMessage): _borrow_stream_ptr = staticmethod(native_bt.message_discarded_packets_borrow_stream) _set_count = staticmethod(native_bt.message_discarded_packets_set_count) - _item_name = 'packet' + _item_name = "packet" _MESSAGE_TYPE_TO_CLS = { diff --git a/src/bindings/python/bt2/bt2/message_iterator.py b/src/bindings/python/bt2/bt2/message_iterator.py index 62c5610c..e2efa732 100644 --- a/src/bindings/python/bt2/bt2/message_iterator.py +++ b/src/bindings/python/bt2/bt2/message_iterator.py @@ -33,7 +33,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera self._ptr ) utils._handle_func_status( - status, 'unexpected error: cannot advance the message iterator' + status, "unexpected error: cannot advance the message iterator" ) self._current_msgs = msgs self._at = 0 @@ -47,7 +47,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera (status, res) = native_bt.message_iterator_can_seek_beginning(self._ptr) utils._handle_func_status( status, - 'cannot check whether or not message iterator can seek its beginning', + "cannot check whether or not message iterator can seek its beginning", ) return res != 0 @@ -57,7 +57,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera self._at = 0 status = native_bt.message_iterator_seek_beginning(self._ptr) - utils._handle_func_status(status, 'cannot seek message iterator beginning') + utils._handle_func_status(status, "cannot seek message iterator beginning") def can_seek_ns_from_origin(self, ns_from_origin): utils._check_int64(ns_from_origin) @@ -66,7 +66,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera ) utils._handle_func_status( status, - 'cannot check whether or not message iterator can seek given ns from origin', + "cannot check whether or not message iterator can seek given ns from origin", ) return res != 0 @@ -81,7 +81,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera self._ptr, ns_from_origin ) utils._handle_func_status( - status, 'message iterator cannot seek given ns from origin' + status, "message iterator cannot seek given ns from origin" ) @property @@ -184,12 +184,12 @@ class _UserMessageIterator(_MessageIterator): # read it and use that result. # - Otherwise, the presence or absence of a `_user_seek_beginning` # method indicates whether the iterator can seek beginning. - if hasattr(self, '_user_can_seek_beginning'): + if hasattr(self, "_user_can_seek_beginning"): can_seek_beginning = self._user_can_seek_beginning() utils._check_bool(can_seek_beginning) return can_seek_beginning else: - return hasattr(self, '_user_seek_beginning') + return hasattr(self, "_user_seek_beginning") def _bt_seek_beginning_from_native(self): self._user_seek_beginning() @@ -204,12 +204,12 @@ class _UserMessageIterator(_MessageIterator): # - Otherwise, if there is a `_user_seek_ns_from_origin` method, # we presume it's possible. - if hasattr(self, '_user_can_seek_ns_from_origin'): + if hasattr(self, "_user_can_seek_ns_from_origin"): can_seek_ns_from_origin = self._user_can_seek_ns_from_origin(ns_from_origin) utils._check_bool(can_seek_ns_from_origin) return can_seek_ns_from_origin else: - return hasattr(self, '_user_seek_ns_from_origin') + return hasattr(self, "_user_seek_ns_from_origin") def _bt_seek_ns_from_origin_from_native(self, ns_from_origin): self._user_seek_ns_from_origin(ns_from_origin) @@ -218,7 +218,7 @@ class _UserMessageIterator(_MessageIterator): utils._check_type(input_port, bt2_port._UserComponentInputPort) if not input_port.is_connected: - raise ValueError('input port is not connected') + raise ValueError("input port is not connected") ( status, @@ -226,7 +226,7 @@ class _UserMessageIterator(_MessageIterator): ) = native_bt.bt2_message_iterator_create_from_message_iterator( self._bt_ptr, input_port._ptr ) - utils._handle_func_status(status, 'cannot create message iterator object') + utils._handle_func_status(status, "cannot create message iterator object") assert msg_iter_ptr is not None return _UserComponentInputPortMessageIterator(msg_iter_ptr) @@ -242,7 +242,7 @@ class _UserMessageIterator(_MessageIterator): if default_clock_snapshot is not None: if event_class.stream_class.default_clock_class is None: raise ValueError( - 'event messages in this stream must not have a default clock snapshot' + "event messages in this stream must not have a default clock snapshot" ) utils._check_uint64(default_clock_snapshot) @@ -258,7 +258,7 @@ class _UserMessageIterator(_MessageIterator): else: if event_class.stream_class.default_clock_class is not None: raise ValueError( - 'event messages in this stream must have a default clock snapshot' + "event messages in this stream must have a default clock snapshot" ) if event_class.stream_class.supports_packets: @@ -271,7 +271,7 @@ class _UserMessageIterator(_MessageIterator): ) if ptr is None: - raise bt2._MemoryError('cannot create event message object') + raise bt2._MemoryError("cannot create event message object") return bt2_message._EventMessage(ptr) @@ -282,7 +282,7 @@ class _UserMessageIterator(_MessageIterator): ) if ptr is None: - raise bt2._MemoryError('cannot create inactivity message object') + raise bt2._MemoryError("cannot create inactivity message object") return bt2_message._MessageIteratorInactivityMessage(ptr) @@ -291,7 +291,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_stream_beginning_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError('cannot create stream beginning message object') + raise bt2._MemoryError("cannot create stream beginning message object") msg = bt2_message._StreamBeginningMessage(ptr) @@ -305,7 +305,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_stream_end_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError('cannot create stream end message object') + raise bt2._MemoryError("cannot create stream end message object") msg = bt2_message._StreamEndMessage(ptr) @@ -336,7 +336,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_packet_beginning_create(self._bt_ptr, packet._ptr) if ptr is None: - raise bt2._MemoryError('cannot create packet beginning message object') + raise bt2._MemoryError("cannot create packet beginning message object") return bt2_message._PacketBeginningMessage(ptr) @@ -362,7 +362,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_packet_end_create(self._bt_ptr, packet._ptr) if ptr is None: - raise bt2._MemoryError('cannot create packet end message object') + raise bt2._MemoryError("cannot create packet end message object") return bt2_message._PacketEndMessage(ptr) @@ -372,12 +372,12 @@ class _UserMessageIterator(_MessageIterator): utils._check_type(stream, bt2_stream._Stream) if not stream.cls.supports_discarded_events: - raise ValueError('stream class does not support discarded events') + raise ValueError("stream class does not support discarded events") if stream.cls.discarded_events_have_default_clock_snapshots: if beg_clock_snapshot is None or end_clock_snapshot is None: raise ValueError( - 'discarded events have default clock snapshots for this stream class' + "discarded events have default clock snapshots for this stream class" ) utils._check_uint64(beg_clock_snapshot) @@ -385,7 +385,7 @@ class _UserMessageIterator(_MessageIterator): if beg_clock_snapshot > end_clock_snapshot: raise ValueError( - 'beginning default clock snapshot value ({}) is greater than end default clock snapshot value ({})'.format( + "beginning default clock snapshot value ({}) is greater than end default clock snapshot value ({})".format( beg_clock_snapshot, end_clock_snapshot ) ) @@ -398,13 +398,13 @@ class _UserMessageIterator(_MessageIterator): else: if beg_clock_snapshot is not None or end_clock_snapshot is not None: raise ValueError( - 'discarded events have no default clock snapshots for this stream class' + "discarded events have no default clock snapshots for this stream class" ) ptr = native_bt.message_discarded_events_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError('cannot discarded events message object') + raise bt2._MemoryError("cannot discarded events message object") msg = bt2_message._DiscardedEventsMessage(ptr) @@ -419,12 +419,12 @@ class _UserMessageIterator(_MessageIterator): utils._check_type(stream, bt2_stream._Stream) if not stream.cls.supports_discarded_packets: - raise ValueError('stream class does not support discarded packets') + raise ValueError("stream class does not support discarded packets") if stream.cls.discarded_packets_have_default_clock_snapshots: if beg_clock_snapshot is None or end_clock_snapshot is None: raise ValueError( - 'discarded packets have default clock snapshots for this stream class' + "discarded packets have default clock snapshots for this stream class" ) utils._check_uint64(beg_clock_snapshot) @@ -432,7 +432,7 @@ class _UserMessageIterator(_MessageIterator): if beg_clock_snapshot > end_clock_snapshot: raise ValueError( - 'beginning default clock snapshot value ({}) is greater than end default clock snapshot value ({})'.format( + "beginning default clock snapshot value ({}) is greater than end default clock snapshot value ({})".format( beg_clock_snapshot, end_clock_snapshot ) ) @@ -445,13 +445,13 @@ class _UserMessageIterator(_MessageIterator): else: if beg_clock_snapshot is not None or end_clock_snapshot is not None: raise ValueError( - 'discarded packets have no default clock snapshots for this stream class' + "discarded packets have no default clock snapshots for this stream class" ) ptr = native_bt.message_discarded_packets_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError('cannot discarded packets message object') + raise bt2._MemoryError("cannot discarded packets message object") msg = bt2_message._DiscardedPacketsMessage(ptr) diff --git a/src/bindings/python/bt2/bt2/mip.py b/src/bindings/python/bt2/bt2/mip.py index 9bf76737..552c7b2a 100644 --- a/src/bindings/python/bt2/bt2/mip.py +++ b/src/bindings/python/bt2/bt2/mip.py @@ -13,10 +13,10 @@ def get_greatest_operative_mip_version( comp_descr_set_ptr = native_bt.component_descriptor_set_create() if comp_descr_set_ptr is None: - raise bt2._MemoryError('cannot create component descriptor set object') + raise bt2._MemoryError("cannot create component descriptor set object") if len(component_descriptors) == 0: - raise ValueError('no component descriptors') + raise ValueError("no component descriptors") try: for descr in component_descriptors: @@ -33,7 +33,7 @@ def get_greatest_operative_mip_version( comp_descr_set_ptr, base_cc_ptr, params_ptr, descr.obj ) utils._handle_func_status( - status, 'cannot add descriptor to component descriptor set' + status, "cannot add descriptor to component descriptor set" ) status, version = native_bt.get_greatest_operative_mip_version( @@ -43,7 +43,7 @@ def get_greatest_operative_mip_version( if status == native_bt.__BT_FUNC_STATUS_NO_MATCH: return None - utils._handle_func_status(status, 'cannot get greatest operative MIP version') + utils._handle_func_status(status, "cannot get greatest operative MIP version") return version finally: native_bt.component_descriptor_set_put_ref(comp_descr_set_ptr) diff --git a/src/bindings/python/bt2/bt2/object.py b/src/bindings/python/bt2/bt2/object.py index 22000e21..fed138ec 100644 --- a/src/bindings/python/bt2/bt2/object.py +++ b/src/bindings/python/bt2/bt2/object.py @@ -20,7 +20,7 @@ class _BaseObject: return int(self._ptr) def __repr__(self): - return '<{}.{} object @ {}>'.format( + return "<{}.{} object @ {}>".format( self.__class__.__module__, self.__class__.__name__, hex(self.addr) ) diff --git a/src/bindings/python/bt2/bt2/plugin.py b/src/bindings/python/bt2/bt2/plugin.py index 8ce94fe9..6888cb12 100644 --- a/src/bindings/python/bt2/bt2/plugin.py +++ b/src/bindings/python/bt2/bt2/plugin.py @@ -28,7 +28,7 @@ def find_plugins_in_path(path, recurse=True, fail_on_load_error=False): if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, 'failed to find plugins') + utils._handle_func_status(status, "failed to find plugins") assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) @@ -58,7 +58,7 @@ def find_plugins( if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, 'failed to find plugins') + utils._handle_func_status(status, "failed to find plugins") assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) @@ -85,7 +85,7 @@ def find_plugin( if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, 'failed to find plugin') + utils._handle_func_status(status, "failed to find plugin") assert ptr is not None return _Plugin._create_from_ptr(ptr) @@ -134,12 +134,12 @@ class _PluginVersion: return self._extra def __str__(self): - extra = '' + extra = "" if self._extra is not None: extra = self._extra - return '{}.{}.{}{}'.format(self._major, self._minor, self._patch, extra) + return "{}.{}.{}{}".format(self._major, self._minor, self._patch, extra) class _PluginComponentClassesIterator(collections.abc.Iterator): diff --git a/src/bindings/python/bt2/bt2/port.py b/src/bindings/python/bt2/bt2/port.py index 4206b3f0..0d648478 100644 --- a/src/bindings/python/bt2/bt2/port.py +++ b/src/bindings/python/bt2/bt2/port.py @@ -15,7 +15,7 @@ def _create_from_const_ptr_and_get_ref(ptr, port_type): cls = _PORT_TYPE_TO_PYCLS.get(port_type, None) if cls is None: - raise TypeError('unknown port type: {}'.format(port_type)) + raise TypeError("unknown port type: {}".format(port_type)) return cls._create_from_ptr_and_get_ref(ptr) @@ -24,7 +24,7 @@ def _create_self_from_ptr_and_get_ref(ptr, port_type): cls = _PORT_TYPE_TO_USER_PYCLS.get(port_type, None) if cls is None: - raise TypeError('unknown port type: {}'.format(port_type)) + raise TypeError("unknown port type: {}".format(port_type)) return cls._create_from_ptr_and_get_ref(ptr) diff --git a/src/bindings/python/bt2/bt2/py_plugin.py b/src/bindings/python/bt2/bt2/py_plugin.py index 21fb2d66..6f067e8b 100644 --- a/src/bindings/python/bt2/bt2/py_plugin.py +++ b/src/bindings/python/bt2/bt2/py_plugin.py @@ -13,7 +13,7 @@ _plugin_infos = {} def plugin_component_class(component_class): if not issubclass(component_class, bt2_component._UserComponent): - raise TypeError('component class is not a subclass of a user component class') + raise TypeError("component class is not a subclass of a user component class") component_class._bt_plugin_component_class = None return component_class @@ -41,7 +41,7 @@ def register_plugin( if version is not None: if not _validate_version(version): raise ValueError( - 'wrong version: expecting a tuple: (major, minor, patch) or (major, minor, patch, extra)' + "wrong version: expecting a tuple: (major, minor, patch) or (major, minor, patch, extra)" ) sys.modules[module_name]._bt_plugin_info = _PluginInfo( @@ -96,20 +96,20 @@ def _try_load_plugin_module(path): import hashlib if path is None: - raise TypeError('missing path') + raise TypeError("missing path") # In order to load the module uniquely from its path, even from # different files which have the same basename, we hash the path # and prefix with `bt_plugin_`. This is its key in sys.modules. h = hashlib.sha256() h.update(path.encode()) - module_name = 'bt_plugin_{}'.format(h.hexdigest()) + module_name = "bt_plugin_{}".format(h.hexdigest()) assert module_name not in sys.modules # try loading the module: any raised exception is catched by the caller mod = importlib.machinery.SourceFileLoader(module_name, path).load_module() # we have the module: look for its plugin info first - if not hasattr(mod, '_bt_plugin_info'): + if not hasattr(mod, "_bt_plugin_info"): raise RuntimeError("missing '_bt_plugin_info' module attribute") plugin_info = mod._bt_plugin_info @@ -119,7 +119,7 @@ def _try_load_plugin_module(path): if not inspect.isclass(obj): return False - if not hasattr(obj, '_bt_plugin_component_class'): + if not hasattr(obj, "_bt_plugin_component_class"): return False return True diff --git a/src/bindings/python/bt2/bt2/query_executor.py b/src/bindings/python/bt2/bt2/query_executor.py index a5debfbf..354404a6 100644 --- a/src/bindings/python/bt2/bt2/query_executor.py +++ b/src/bindings/python/bt2/bt2/query_executor.py @@ -65,7 +65,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): cc_ptr ): raise ValueError( - 'cannot pass a Python object to a non-Python component class' + "cannot pass a Python object to a non-Python component class" ) ptr = native_bt.bt2_query_executor_create( @@ -73,7 +73,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): ) if ptr is None: - raise bt2._MemoryError('cannot create query executor object') + raise bt2._MemoryError("cannot create query executor object") super().__init__(ptr) @@ -107,7 +107,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): def query(self): status, result_ptr = native_bt.query_executor_query(self._ptr) - utils._handle_func_status(status, 'cannot query component class') + utils._handle_func_status(status, "cannot query component class") assert result_ptr is not None return bt2_value._create_from_const_ptr(result_ptr) @@ -118,7 +118,7 @@ class _PrivateQueryExecutor(_QueryExecutorCommon): def _check_validity(self): if self._ptr is None: - raise RuntimeError('this object is not valid anymore') + raise RuntimeError("this object is not valid anymore") def _as_query_executor_ptr(self): self._check_validity() diff --git a/src/bindings/python/bt2/bt2/stream.py b/src/bindings/python/bt2/bt2/stream.py index 5fea4107..f1329623 100644 --- a/src/bindings/python/bt2/bt2/stream.py +++ b/src/bindings/python/bt2/bt2/stream.py @@ -71,13 +71,13 @@ class _Stream(_StreamConst): def create_packet(self): if not self.cls.supports_packets: raise ValueError( - 'cannot create packet: stream class does not support packets' + "cannot create packet: stream class does not support packets" ) packet_ptr = native_bt.packet_create(self._ptr) if packet_ptr is None: - raise bt2._MemoryError('cannot create packet object') + raise bt2._MemoryError("cannot create packet object") return bt2_packet._Packet._create_from_ptr(packet_ptr) diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index 18e970c9..885ba746 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -214,14 +214,14 @@ class _StreamClass(_StreamClassConst): if self.assigns_automatic_event_class_id: if id is not None: raise ValueError( - 'id provided, but stream class assigns automatic event class ids' + "id provided, but stream class assigns automatic event class ids" ) ec_ptr = native_bt.event_class_create(self._ptr) else: if id is None: raise ValueError( - 'id not provided, but stream class does not assign automatic event class ids' + "id not provided, but stream class does not assign automatic event class ids" ) utils._check_uint64(id) @@ -345,7 +345,7 @@ class _StreamClass(_StreamClassConst): if packet_context_field_class is not None: if not supports_packets: raise ValueError( - 'cannot have a packet context field class without supporting packets' + "cannot have a packet context field class without supporting packets" ) utils._check_type( @@ -376,11 +376,11 @@ class _StreamClass(_StreamClassConst): if not supports_packets: if packets_have_beginning_default_clock_snapshot: raise ValueError( - 'cannot not support packets, but have packet beginning default clock snapshot' + "cannot not support packets, but have packet beginning default clock snapshot" ) if packets_have_end_default_clock_snapshot: raise ValueError( - 'cannot not support packets, but have packet end default clock snapshots' + "cannot not support packets, but have packet end default clock snapshots" ) # Discarded events @@ -390,12 +390,12 @@ class _StreamClass(_StreamClassConst): if discarded_events_have_default_clock_snapshots: if not supports_discarded_events: raise ValueError( - 'cannot not support discarded events, but have default clock snapshots for discarded event messages' + "cannot not support discarded events, but have default clock snapshots for discarded event messages" ) if default_clock_class is None: raise ValueError( - 'cannot have no default clock class, but have default clock snapshots for discarded event messages' + "cannot have no default clock class, but have default clock snapshots for discarded event messages" ) # Discarded packets @@ -404,16 +404,16 @@ class _StreamClass(_StreamClassConst): if supports_discarded_packets and not supports_packets: raise ValueError( - 'cannot support discarded packets, but not support packets' + "cannot support discarded packets, but not support packets" ) if discarded_packets_have_default_clock_snapshots: if not supports_discarded_packets: raise ValueError( - 'cannot not support discarded packets, but have default clock snapshots for discarded packet messages' + "cannot not support discarded packets, but have default clock snapshots for discarded packet messages" ) if default_clock_class is None: raise ValueError( - 'cannot have no default clock class, but have default clock snapshots for discarded packet messages' + "cannot have no default clock class, but have default clock snapshots for discarded packet messages" ) diff --git a/src/bindings/python/bt2/bt2/trace.py b/src/bindings/python/bt2/bt2/trace.py index a582f8fd..1c56b034 100644 --- a/src/bindings/python/bt2/bt2/trace.py +++ b/src/bindings/python/bt2/bt2/trace.py @@ -63,7 +63,7 @@ class _TraceEnvironment(_TraceEnvironmentConst, collections.abc.MutableMapping): elif isinstance(value, int): set_env_entry_fn = native_bt.trace_set_environment_entry_integer else: - raise TypeError('expected str or int, got {}'.format(type(value))) + raise TypeError("expected str or int, got {}".format(type(value))) status = set_env_entry_fn(self._trace._ptr, key, value) utils._handle_func_status(status, "cannot set trace object's environment entry") @@ -144,7 +144,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): return self._trace_env_pycls(self) def add_destruction_listener(self, listener): - '''Add a listener to be called when the trace is destroyed.''' + """Add a listener to be called when the trace is destroyed.""" if not callable(listener): raise TypeError("'listener' parameter is not callable") @@ -157,7 +157,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): status, listener_id = fn(self._ptr, listener_from_native) utils._handle_func_status( - status, 'cannot add destruction listener to trace object' + status, "cannot add destruction listener to trace object" ) handle._set_listener_id(listener_id) @@ -169,11 +169,11 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): if listener_handle._addr != self.addr: raise ValueError( - 'This trace destruction listener does not match the trace object.' + "This trace destruction listener does not match the trace object." ) if listener_handle._listener_id is None: - raise ValueError('This trace destruction listener was already removed.') + raise ValueError("This trace destruction listener was already removed.") status = native_bt.trace_remove_destruction_listener( self._ptr, listener_handle._listener_id @@ -236,7 +236,7 @@ class _Trace(_TraceConst): ) if stream_ptr is None: - raise bt2._MemoryError('cannot create stream object') + raise bt2._MemoryError("cannot create stream object") stream = bt2_stream._Stream._create_from_ptr(stream_ptr) diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index ebfdbe4e..f66f3855 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -94,7 +94,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): fn = native_bt.bt2_trace_class_add_destruction_listener status, listener_id = fn(self._ptr, listener_from_native) utils._handle_func_status( - status, 'cannot add destruction listener to trace class object' + status, "cannot add destruction listener to trace class object" ) handle._set_listener_id(listener_id) @@ -106,12 +106,12 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): if listener_handle._addr != self.addr: raise ValueError( - 'This trace class destruction listener does not match the trace class object.' + "This trace class destruction listener does not match the trace class object." ) if listener_handle._listener_id is None: raise ValueError( - 'This trace class destruction listener was already removed.' + "This trace class destruction listener was already removed." ) status = native_bt.trace_class_remove_destruction_listener( @@ -142,7 +142,7 @@ class _TraceClass(_TraceClassConst): trace_ptr = native_bt.trace_create(self._ptr) if trace_ptr is None: - raise bt2._MemoryError('cannot create trace class object') + raise bt2._MemoryError("cannot create trace class object") trace = bt2_trace._Trace._create_from_ptr(trace_ptr) @@ -200,14 +200,14 @@ class _TraceClass(_TraceClassConst): if self.assigns_automatic_stream_class_id: if id is not None: raise ValueError( - 'id provided, but trace class assigns automatic stream class ids' + "id provided, but trace class assigns automatic stream class ids" ) sc_ptr = native_bt.stream_class_create(self._ptr) else: if id is None: raise ValueError( - 'id not provided, but trace class does not assign automatic stream class ids' + "id not provided, but trace class does not assign automatic stream class ids" ) utils._check_uint64(id) @@ -274,7 +274,7 @@ class _TraceClass(_TraceClassConst): def _check_field_class_create_status(self, ptr, type_name): if ptr is None: - raise bt2._MemoryError('cannot create {} field class'.format(type_name)) + raise bt2._MemoryError("cannot create {} field class".format(type_name)) @staticmethod def _set_field_class_user_attrs(fc, user_attributes): @@ -283,7 +283,7 @@ class _TraceClass(_TraceClassConst): def create_bool_field_class(self, user_attributes=None): field_class_ptr = native_bt.field_class_bool_create(self._ptr) - self._check_field_class_create_status(field_class_ptr, 'boolean') + self._check_field_class_create_status(field_class_ptr, "boolean") fc = bt2_field_class._BoolFieldClass._create_from_ptr(field_class_ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -293,13 +293,13 @@ class _TraceClass(_TraceClassConst): if length < 1 or length > 64: raise ValueError( - 'invalid length {}: expecting a value in the [1, 64] range'.format( + "invalid length {}: expecting a value in the [1, 64] range".format( length ) ) field_class_ptr = native_bt.field_class_bit_array_create(self._ptr, length) - self._check_field_class_create_status(field_class_ptr, 'bit array') + self._check_field_class_create_status(field_class_ptr, "bit array") fc = bt2_field_class._BitArrayFieldClass._create_from_ptr(field_class_ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -333,7 +333,7 @@ class _TraceClass(_TraceClassConst): return self._create_integer_field_class( native_bt.field_class_integer_signed_create, bt2_field_class._SignedIntegerFieldClass, - 'signed integer', + "signed integer", field_value_range, preferred_display_base, user_attributes, @@ -345,7 +345,7 @@ class _TraceClass(_TraceClassConst): return self._create_integer_field_class( native_bt.field_class_integer_unsigned_create, bt2_field_class._UnsignedIntegerFieldClass, - 'unsigned integer', + "unsigned integer", field_value_range, preferred_display_base, user_attributes, @@ -357,7 +357,7 @@ class _TraceClass(_TraceClassConst): return self._create_integer_field_class( native_bt.field_class_enumeration_signed_create, bt2_field_class._SignedEnumerationFieldClass, - 'signed enumeration', + "signed enumeration", field_value_range, preferred_display_base, user_attributes, @@ -369,7 +369,7 @@ class _TraceClass(_TraceClassConst): return self._create_integer_field_class( native_bt.field_class_enumeration_unsigned_create, bt2_field_class._UnsignedEnumerationFieldClass, - 'unsigned enumeration', + "unsigned enumeration", field_value_range, preferred_display_base, user_attributes, @@ -377,7 +377,7 @@ class _TraceClass(_TraceClassConst): def create_single_precision_real_field_class(self, user_attributes=None): field_class_ptr = native_bt.field_class_real_single_precision_create(self._ptr) - self._check_field_class_create_status(field_class_ptr, 'single-precision real') + self._check_field_class_create_status(field_class_ptr, "single-precision real") field_class = bt2_field_class._SinglePrecisionRealFieldClass._create_from_ptr( field_class_ptr @@ -389,7 +389,7 @@ class _TraceClass(_TraceClassConst): def create_double_precision_real_field_class(self, user_attributes=None): field_class_ptr = native_bt.field_class_real_double_precision_create(self._ptr) - self._check_field_class_create_status(field_class_ptr, 'double-precision real') + self._check_field_class_create_status(field_class_ptr, "double-precision real") field_class = bt2_field_class._DoublePrecisionRealFieldClass._create_from_ptr( field_class_ptr @@ -401,14 +401,14 @@ class _TraceClass(_TraceClassConst): def create_structure_field_class(self, user_attributes=None): field_class_ptr = native_bt.field_class_structure_create(self._ptr) - self._check_field_class_create_status(field_class_ptr, 'structure') + self._check_field_class_create_status(field_class_ptr, "structure") fc = bt2_field_class._StructureFieldClass._create_from_ptr(field_class_ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc def create_string_field_class(self, user_attributes=None): field_class_ptr = native_bt.field_class_string_create(self._ptr) - self._check_field_class_create_status(field_class_ptr, 'string') + self._check_field_class_create_status(field_class_ptr, "string") fc = bt2_field_class._StringFieldClass._create_from_ptr(field_class_ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -417,7 +417,7 @@ class _TraceClass(_TraceClassConst): utils._check_type(elem_fc, bt2_field_class._FieldClass) utils._check_uint64(length) ptr = native_bt.field_class_array_static_create(self._ptr, elem_fc._ptr, length) - self._check_field_class_create_status(ptr, 'static array') + self._check_field_class_create_status(ptr, "static array") fc = bt2_field_class._StaticArrayFieldClass._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -435,7 +435,7 @@ class _TraceClass(_TraceClassConst): ptr = native_bt.field_class_array_dynamic_create( self._ptr, elem_fc._ptr, length_fc_ptr ) - self._check_field_class_create_status(ptr, 'dynamic array') + self._check_field_class_create_status(ptr, "dynamic array") fc = bt2_field_class._obj_type_from_field_class_ptr(ptr)._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -447,7 +447,7 @@ class _TraceClass(_TraceClassConst): ptr = native_bt.field_class_option_without_selector_create( self._ptr, content_fc._ptr ) - self._check_field_class_create_status(ptr, 'option') + self._check_field_class_create_status(ptr, "option") fc = bt2_field_class._obj_type_from_field_class_ptr(ptr)._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -461,7 +461,7 @@ class _TraceClass(_TraceClassConst): ptr = native_bt.field_class_option_with_selector_field_bool_create( self._ptr, content_fc._ptr, selector_fc._ptr ) - self._check_field_class_create_status(ptr, 'option') + self._check_field_class_create_status(ptr, "option") fc = bt2_field_class._obj_type_from_field_class_ptr(ptr)._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) fc._selector_is_reversed = selector_is_reversed @@ -474,7 +474,7 @@ class _TraceClass(_TraceClassConst): utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass) if len(ranges) == 0: - raise ValueError('integer range set is empty') + raise ValueError("integer range set is empty") if isinstance(selector_fc, bt2_field_class._UnsignedIntegerFieldClass): utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet) @@ -489,7 +489,7 @@ class _TraceClass(_TraceClassConst): ) ) - self._check_field_class_create_status(ptr, 'option') + self._check_field_class_create_status(ptr, "option") fc = bt2_field_class._obj_type_from_field_class_ptr(ptr)._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc @@ -502,7 +502,7 @@ class _TraceClass(_TraceClassConst): selector_fc_ptr = selector_fc._ptr ptr = native_bt.field_class_variant_create(self._ptr, selector_fc_ptr) - self._check_field_class_create_status(ptr, 'variant') + self._check_field_class_create_status(ptr, "variant") fc = bt2_field_class._obj_type_from_field_class_ptr(ptr)._create_from_ptr(ptr) self._set_field_class_user_attrs(fc, user_attributes) return fc diff --git a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py index b9db82cd..ed474cd0 100644 --- a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py +++ b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py @@ -16,7 +16,7 @@ import numbers # a pair of component and ComponentSpec -_ComponentAndSpec = namedtuple('_ComponentAndSpec', ['comp', 'spec']) +_ComponentAndSpec = namedtuple("_ComponentAndSpec", ["comp", "spec"]) class _BaseComponentSpec: @@ -53,7 +53,7 @@ class ComponentSpec(_BaseComponentSpec): logging_level=bt2.LoggingLevel.NONE, ): if type(params) is str: - params = {'inputs': [params]} + params = {"inputs": [params]} super().__init__(params, obj, logging_level) @@ -92,7 +92,7 @@ class ComponentSpec(_BaseComponentSpec): plugin = bt2.find_plugin(plugin_name) if plugin is None: - raise ValueError('no such plugin: {}'.format(plugin_name)) + raise ValueError("no such plugin: {}".format(plugin_name)) if component_class_name in plugin.source_component_classes: comp_class = plugin.source_component_classes[component_class_name] @@ -100,7 +100,7 @@ class ComponentSpec(_BaseComponentSpec): comp_class = plugin.filter_component_classes[component_class_name] else: raise KeyError( - 'source or filter component class `{}` not found in plugin `{}`'.format( + "source or filter component class `{}` not found in plugin `{}`".format( component_class_name, plugin_name ) ) @@ -136,18 +136,18 @@ def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set): ) if res_ptr is None: - raise bt2._MemoryError('cannot auto discover source components') + raise bt2._MemoryError("cannot auto discover source components") res = bt2_value._create_from_ptr(res_ptr) assert type(res) == bt2.MapValue - assert 'status' in res + assert "status" in res - status = res['status'] - utils._handle_func_status(status, 'cannot auto-discover source components') + status = res["status"] + utils._handle_func_status(status, "cannot auto-discover source components") comp_specs = [] - comp_specs_raw = res['results'] + comp_specs_raw = res["results"] assert type(comp_specs_raw) == bt2.ArrayValue used_input_indices = set() @@ -195,7 +195,7 @@ def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set): used_input_indices.add(int(idx)) - params['inputs'] = comp_inputs + params["inputs"] = comp_inputs comp_specs.append( ComponentSpec.from_named_plugin_and_component_class( @@ -213,8 +213,8 @@ def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set): unused_inputs = [str(inputs[x]) for x in unused_input_indices] msg = ( - 'Some auto source component specs did not produce any component: ' - + ', '.join(unused_inputs) + "Some auto source component specs did not produce any component: " + + ", ".join(unused_inputs) ) raise RuntimeError(msg) @@ -244,10 +244,10 @@ class _TraceCollectionMessageIteratorProxySink(bt2_component._UserSinkComponent) def __init__(self, config, params, msg_list): assert type(msg_list) is list self._msg_list = msg_list - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): assert self._msg_list[0] is None @@ -331,7 +331,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): # compute the intersection of the streams in each trace. query_exec = bt2.QueryExecutor( src_comp_and_spec.spec.component_class, - 'babeltrace.trace-infos', + "babeltrace.trace-infos", src_comp_and_spec.spec.params, ) trace_infos = query_exec.query() @@ -339,21 +339,21 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): for trace_info in trace_infos: begin = max( [ - stream['range-ns']['begin'] - for stream in trace_info['stream-infos'] + stream["range-ns"]["begin"] + for stream in trace_info["stream-infos"] ] ) end = min( - [stream['range-ns']['end'] for stream in trace_info['stream-infos']] + [stream["range-ns"]["end"] for stream in trace_info["stream-infos"]] ) # Each port associated to this trace will have this computed # range. - for stream in trace_info['stream-infos']: + for stream in trace_info["stream-infos"]: # A port name is unique within a component, but not # necessarily across all components. Use a component # and port name pair to make it unique across the graph. - port_name = str(stream['port-name']) + port_name = str(stream["port-name"]) key = (src_comp_and_spec.comp.addr, port_name) self._stream_inter_port_to_range[key] = (begin, end) @@ -387,30 +387,30 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): def _create_stream_intersection_trimmer(self, component, port): key = (component.addr, port.name) begin, end = self._stream_inter_port_to_range[key] - name = 'trimmer-{}-{}'.format(component.name, port.name) + name = "trimmer-{}-{}".format(component.name, port.name) return self._create_trimmer(begin, end, name) def _create_muxer(self): - plugin = bt2.find_plugin('utils') + plugin = bt2.find_plugin("utils") if plugin is None: raise RuntimeError('cannot find "utils" plugin (needed for the muxer)') - if 'muxer' not in plugin.filter_component_classes: + if "muxer" not in plugin.filter_component_classes: raise RuntimeError( 'cannot find "muxer" filter component class in "utils" plugin' ) - comp_cls = plugin.filter_component_classes['muxer'] - return self._graph.add_component(comp_cls, 'muxer') + comp_cls = plugin.filter_component_classes["muxer"] + return self._graph.add_component(comp_cls, "muxer") def _create_trimmer(self, begin_ns, end_ns, name): - plugin = bt2.find_plugin('utils') + plugin = bt2.find_plugin("utils") if plugin is None: raise RuntimeError('cannot find "utils" plugin (needed for the trimmer)') - if 'trimmer' not in plugin.filter_component_classes: + if "trimmer" not in plugin.filter_component_classes: raise RuntimeError( 'cannot find "trimmer" filter component class in "utils" plugin' ) @@ -420,15 +420,15 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): def ns_to_string(ns): s_part = ns // 1000000000 ns_part = ns % 1000000000 - return '{}.{:09d}'.format(s_part, ns_part) + return "{}.{:09d}".format(s_part, ns_part) if begin_ns is not None: - params['begin'] = ns_to_string(begin_ns) + params["begin"] = ns_to_string(begin_ns) if end_ns is not None: - params['end'] = ns_to_string(end_ns) + params["end"] = ns_to_string(end_ns) - comp_cls = plugin.filter_component_classes['trimmer'] + comp_cls = plugin.filter_component_classes["trimmer"] return self._graph.add_component(comp_cls, name, params) def _get_unique_comp_name(self, comp_cls): @@ -438,7 +438,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): ) if name in [comp_and_spec.comp.name for comp_and_spec in comps_and_specs]: - name += '-{}'.format(self._next_suffix) + name += "-{}".format(self._next_suffix) self._next_suffix += 1 return name @@ -467,8 +467,8 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): # port -> muxer if self._stream_intersection_mode: trimmer_comp = self._create_stream_intersection_trimmer(component, port) - self._graph.connect_ports(port, trimmer_comp.input_ports['in']) - port_to_muxer = trimmer_comp.output_ports['out'] + self._graph.connect_ports(port, trimmer_comp.input_ports["in"]) + port_to_muxer = trimmer_comp.output_ports["out"] else: port_to_muxer = port @@ -503,14 +503,14 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): if self._stream_intersection_mode: # we also need at least one `flt.utils.trimmer` component comp_spec = ComponentSpec.from_named_plugin_and_component_class( - 'utils', 'trimmer' + "utils", "trimmer" ) append_comp_specs_descriptors(descriptors, [comp_spec]) mip_version = bt2.get_greatest_operative_mip_version(descriptors) if mip_version is None: - msg = 'failed to find an operative message interchange protocol version (components are not interoperable)' + msg = "failed to find an operative message interchange protocol version (components are not interoperable)" raise RuntimeError(msg) return mip_version @@ -521,13 +521,13 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): self._muxer_comp = self._create_muxer() if self._begin_ns is not None or self._end_ns is not None: - trimmer_comp = self._create_trimmer(self._begin_ns, self._end_ns, 'trimmer') + trimmer_comp = self._create_trimmer(self._begin_ns, self._end_ns, "trimmer") self._graph.connect_ports( - self._muxer_comp.output_ports['out'], trimmer_comp.input_ports['in'] + self._muxer_comp.output_ports["out"], trimmer_comp.input_ports["in"] ) - last_flt_out_port = trimmer_comp.output_ports['out'] + last_flt_out_port = trimmer_comp.output_ports["out"] else: - last_flt_out_port = self._muxer_comp.output_ports['out'] + last_flt_out_port = self._muxer_comp.output_ports["out"] # create extra filter components (chained) for comp_spec in self._flt_comp_specs: @@ -574,9 +574,9 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): # Add the proxy sink, passing our message list to share consumed # messages with this trace collection message iterator. sink = self._graph.add_component( - _TraceCollectionMessageIteratorProxySink, 'proxy-sink', obj=self._msg_list + _TraceCollectionMessageIteratorProxySink, "proxy-sink", obj=self._msg_list ) - sink_in_port = sink.input_ports['in'] + sink_in_port = sink.input_ports["in"] # connect last filter to proxy sink self._graph.connect_ports(last_flt_out_port, sink_in_port) diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index d7e99ca6..393f7ed8 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -63,9 +63,9 @@ def _check_int64(v, msg=None): if not _is_in_int64_range(v): if msg is None: - msg = 'expecting a signed 64-bit integral value' + msg = "expecting a signed 64-bit integral value" - msg += ' (got {})'.format(v) + msg += " (got {})".format(v) raise ValueError(msg) @@ -74,9 +74,9 @@ def _check_uint64(v, msg=None): if not _is_in_uint64_range(v): if msg is None: - msg = 'expecting an unsigned 64-bit integral value' + msg = "expecting an unsigned 64-bit integral value" - msg += ' (got {})'.format(v) + msg += " (got {})".format(v) raise ValueError(msg) @@ -92,7 +92,7 @@ def _check_alignment(a): _check_uint64(a) if not _is_pow2(a): - raise ValueError('{} is not a power of two'.format(a)) + raise ValueError("{} is not a power of two".format(a)) def _check_log_level(log_level): diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index 77d14879..04016dec 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -95,7 +95,7 @@ class _ValueConst(object._SharedObject, metaclass=abc.ABCMeta): def _check_create_status(self, ptr): if ptr is None: raise bt2._MemoryError( - 'cannot create {} value object'.format(self._NAME.lower()) + "cannot create {} value object".format(self._NAME.lower()) ) @@ -247,7 +247,7 @@ class _IntegralValue(_IntegralValueConst, _NumericValue): class _BoolValueConst(_IntegralValueConst): - _NAME = 'Const boolean' + _NAME = "Const boolean" def __bool__(self): return self._value @@ -262,7 +262,7 @@ class _BoolValueConst(_IntegralValueConst): class BoolValue(_BoolValueConst, _IntegralValue): - _NAME = 'Boolean' + _NAME = "Boolean" def __init__(self, value=None): if value is None: @@ -312,7 +312,7 @@ class _IntegerValue(_IntegerValueConst, _IntegralValue): @classmethod def _value_to_int(cls, value): if not isinstance(value, numbers.Integral): - raise TypeError('expecting an integral number object') + raise TypeError("expecting an integral number object") value = int(value) cls._check_int_range(value) @@ -325,12 +325,12 @@ class _IntegerValue(_IntegerValueConst, _IntegralValue): class _UnsignedIntegerValueConst(_IntegerValueConst): - _NAME = 'Const unsigned integer' + _NAME = "Const unsigned integer" _get_value = staticmethod(native_bt.value_integer_unsigned_get) class UnsignedIntegerValue(_UnsignedIntegerValueConst, _IntegerValue): - _NAME = 'Unsigned integer' + _NAME = "Unsigned integer" _check_int_range = staticmethod(utils._check_uint64) _create_default_value = staticmethod(native_bt.value_integer_unsigned_create) _create_value = staticmethod(native_bt.value_integer_unsigned_create_init) @@ -338,12 +338,12 @@ class UnsignedIntegerValue(_UnsignedIntegerValueConst, _IntegerValue): class _SignedIntegerValueConst(_IntegerValueConst): - _NAME = 'Const signed integer' + _NAME = "Const signed integer" _get_value = staticmethod(native_bt.value_integer_signed_get) class SignedIntegerValue(_SignedIntegerValueConst, _IntegerValue): - _NAME = 'Signed integer' + _NAME = "Signed integer" _check_int_range = staticmethod(utils._check_int64) _create_default_value = staticmethod(native_bt.value_integer_signed_create) _create_value = staticmethod(native_bt.value_integer_signed_create_init) @@ -351,7 +351,7 @@ class SignedIntegerValue(_SignedIntegerValueConst, _IntegerValue): class _RealValueConst(_NumericValueConst, numbers.Real): - _NAME = 'Const real number' + _NAME = "Const real number" @property def _value(self): @@ -359,7 +359,7 @@ class _RealValueConst(_NumericValueConst, numbers.Real): class RealValue(_RealValueConst, _NumericValue): - _NAME = 'Real number' + _NAME = "Real number" def __init__(self, value=None): if value is None: @@ -386,7 +386,7 @@ class RealValue(_RealValueConst, _NumericValue): @functools.total_ordering class _StringValueConst(collections.abc.Sequence, _Value): - _NAME = 'Const string' + _NAME = "Const string" @classmethod def _value_to_str(cls, value): @@ -429,7 +429,7 @@ class _StringValueConst(collections.abc.Sequence, _Value): class StringValue(_StringValueConst, _Value): - _NAME = 'String' + _NAME = "String" def __init__(self, value=None): if value is None: @@ -464,7 +464,7 @@ class _Container(_ContainerConst): class _ArrayValueConst(_ContainerConst, collections.abc.Sequence, _ValueConst): - _NAME = 'Const array' + _NAME = "Const array" _borrow_element_by_index = staticmethod( native_bt.value_array_borrow_element_by_index_const ) @@ -501,7 +501,7 @@ class _ArrayValueConst(_ContainerConst, collections.abc.Sequence, _ValueConst): index = int(index) if index < 0 or index >= len(self): - raise IndexError('array value object index is out of range') + raise IndexError("array value object index is out of range") def __getitem__(self, index): self._check_index(index) @@ -510,11 +510,11 @@ class _ArrayValueConst(_ContainerConst, collections.abc.Sequence, _ValueConst): return self._create_value_from_ptr_and_get_ref(ptr) def __repr__(self): - return '[{}]'.format(', '.join([repr(v) for v in self])) + return "[{}]".format(", ".join([repr(v) for v in self])) class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence, _Value): - _NAME = 'Array' + _NAME = "Array" _borrow_element_by_index = staticmethod( native_bt.value_array_borrow_element_by_index ) @@ -572,7 +572,7 @@ class _MapValueKeyIterator(collections.abc.Iterator): keys_ptr = native_bt.value_map_get_keys(map_obj._ptr) if keys_ptr is None: - raise RuntimeError('unexpected error: cannot get map value object keys') + raise RuntimeError("unexpected error: cannot get map value object keys") self._keys = _create_from_ptr(keys_ptr) @@ -586,7 +586,7 @@ class _MapValueKeyIterator(collections.abc.Iterator): class _MapValueConst(_ContainerConst, collections.abc.Mapping, _ValueConst): - _NAME = 'Const map' + _NAME = "Const map" _borrow_entry_value_ptr = staticmethod(native_bt.value_map_borrow_entry_value_const) def __ne__(self, other): @@ -635,12 +635,12 @@ class _MapValueConst(_ContainerConst, collections.abc.Mapping, _ValueConst): return _MapValueKeyIterator(self) def __repr__(self): - items = ['{}: {}'.format(repr(k), repr(v)) for k, v in self.items()] - return '{{{}}}'.format(', '.join(items)) + items = ["{}: {}".format(repr(k), repr(v)) for k, v in self.items()] + return "{{{}}}".format(", ".join(items)) class MapValue(_MapValueConst, _Container, collections.abc.MutableMapping, _Value): - _NAME = 'Map' + _NAME = "Map" _borrow_entry_value_ptr = staticmethod(native_bt.value_map_borrow_entry_value) def __init__(self, value=None): diff --git a/src/bindings/python/bt2/bt2/version.py.in b/src/bindings/python/bt2/bt2/version.py.in index 81933d4d..635370e3 100644 --- a/src/bindings/python/bt2/bt2/version.py.in +++ b/src/bindings/python/bt2/bt2/version.py.in @@ -2,4 +2,4 @@ # # Copyright (c) 2017 Philippe Proulx -__version__ = '@PACKAGE_VERSION@' +__version__ = "@PACKAGE_VERSION@" diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index 5319214b..44b1dc67 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -23,10 +23,10 @@ original_get_config_vars = distutils.sysconfig.get_config_vars def get_cflags(): - cflags = os.environ.get('CFLAGS') + cflags = os.environ.get("CFLAGS") if cflags is None: - [cflags] = original_get_config_vars('CFLAGS') + [cflags] = original_get_config_vars("CFLAGS") return cflags @@ -40,16 +40,16 @@ def get_cflags(): # by either the Python interprter's CC or the overriden CC don't cause a # build failure. def get_ldshared(): - cc = os.environ.get('CC') - ldflags = os.environ.get('LDFLAGS') - [py_cc] = original_get_config_vars('CC') - [py_ldshared] = original_get_config_vars('LDSHARED') + cc = os.environ.get("CC") + ldflags = os.environ.get("LDFLAGS") + [py_cc] = original_get_config_vars("CC") + [py_ldshared] = original_get_config_vars("LDSHARED") if not py_ldshared.startswith(py_cc): return py_ldshared if cc and ldflags: - return '{} -shared {}'.format(cc, ldflags) + return "{} -shared {}".format(cc, ldflags) elif cc: return cc + py_ldshared[len(py_cc) :] elif ldflags: @@ -60,8 +60,8 @@ def get_ldshared(): def our_get_config_vars(*args): overridden_config_vars = { - 'CFLAGS': get_cflags(), - 'LDSHARED': get_ldshared(), + "CFLAGS": get_cflags(), + "LDSHARED": get_ldshared(), } if len(args) == 0: @@ -87,36 +87,36 @@ distutils.sysconfig.get_config_vars = our_get_config_vars def main(): babeltrace_ext = Extension( - 'bt2._native_bt', - sources=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'], - libraries=['babeltrace2', 'glib-2.0'], + "bt2._native_bt", + sources=["bt2/native_bt.c", "@srcdir@/bt2/logging.c"], + libraries=["babeltrace2", "glib-2.0"], extra_objects=[ - '@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a', - '@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a', - '@top_builddir@/src/common/.libs/libbabeltrace2-common.a', - '@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a', - '@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a', + "@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a", + "@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a", + "@top_builddir@/src/common/.libs/libbabeltrace2-common.a", + "@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a", + "@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a", ], ) dist = setup( - name='bt2', - version='@PACKAGE_VERSION@', - description='Babeltrace 2 Python Bindings', - packages=['bt2'], - package_dir={'bt2': 'bt2'}, + name="bt2", + version="@PACKAGE_VERSION@", + description="Babeltrace 2 Python Bindings", + packages=["bt2"], + package_dir={"bt2": "bt2"}, options={ - 'build': {'build_base': 'build', 'build_lib': 'build/build_lib'}, - 'build_ext': {'build_lib': 'build/build_lib'}, + "build": {"build_base": "build", "build_lib": "build/build_lib"}, + "build_ext": {"build_lib": "build/build_lib"}, }, - url='https://babeltrace.org/', + url="https://babeltrace.org/", ext_modules=[babeltrace_ext], - license='MIT', + license="MIT", classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: The MIT License', - 'Programming Language :: Python :: 3' 'Topic :: System :: Logging', + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: The MIT License", + "Programming Language :: Python :: 3" "Topic :: System :: Logging", ], ) @@ -127,8 +127,8 @@ def main(): # also useful for out-of-tree installs and tests. # It's only relevant to make this check on the `install` command. - if 'install' in dist.command_obj: - install_dir = dist.command_obj['install'].install_libbase + if "install" in dist.command_obj: + install_dir = dist.command_obj["install"].install_libbase if install_dir not in sys.path: # We can't consider this an error because if affects every # distro differently. We only warn the user that some diff --git a/tests/bindings/python/bt2/test_clock_class.py b/tests/bindings/python/bt2/test_clock_class.py index 04df66ad..9707052f 100644 --- a/tests/bindings/python/bt2/test_clock_class.py +++ b/tests/bindings/python/bt2/test_clock_class.py @@ -30,11 +30,11 @@ class ClockClassOffsetTestCase(unittest.TestCase): def test_create_invalid_seconds(self): with self.assertRaises(TypeError): - bt2.ClockClassOffset('hello', 4871232) + bt2.ClockClassOffset("hello", 4871232) def test_create_invalid_cycles(self): with self.assertRaises(TypeError): - bt2.ClockClassOffset(23, 'hello') + bt2.ClockClassOffset(23, "hello") def test_eq(self): cco1 = bt2.ClockClassOffset(23, 42) @@ -81,10 +81,10 @@ class ClockClassTestCase(unittest.TestCase): def test_create_name(self): def f(comp_self): - return comp_self._create_clock_class(name='the_clock') + return comp_self._create_clock_class(name="the_clock") cc = run_in_component_init(f) - self.assertEqual(cc.name, 'the_clock') + self.assertEqual(cc.name, "the_clock") def test_create_invalid_name(self): def f(comp_self): @@ -94,10 +94,10 @@ class ClockClassTestCase(unittest.TestCase): def test_create_description(self): def f(comp_self): - return comp_self._create_clock_class(description='hi people') + return comp_self._create_clock_class(description="hi people") cc = run_in_component_init(f) - self.assertEqual(cc.description, 'hi people') + self.assertEqual(cc.description, "hi people") def test_create_invalid_description(self): def f(comp_self): @@ -114,7 +114,7 @@ class ClockClassTestCase(unittest.TestCase): def test_create_invalid_frequency(self): def f(comp_self): - return comp_self._create_clock_class(frequency='lel') + return comp_self._create_clock_class(frequency="lel") self.assertRaisesInComponentInit(TypeError, f) @@ -127,7 +127,7 @@ class ClockClassTestCase(unittest.TestCase): def test_create_invalid_precision(self): def f(comp_self): - return comp_self._create_clock_class(precision='lel') + return comp_self._create_clock_class(precision="lel") self.assertRaisesInComponentInit(TypeError, f) @@ -177,11 +177,11 @@ class ClockClassTestCase(unittest.TestCase): def test_create_uuid(self): def f(comp_self): return comp_self._create_clock_class( - uuid=uuid.UUID('b43372c32ef0be28444dfc1c5cdafd33') + uuid=uuid.UUID("b43372c32ef0be28444dfc1c5cdafd33") ) cc = run_in_component_init(f) - self.assertEqual(cc.uuid, uuid.UUID('b43372c32ef0be28444dfc1c5cdafd33')) + self.assertEqual(cc.uuid, uuid.UUID("b43372c32ef0be28444dfc1c5cdafd33")) def test_create_invalid_uuid(self): def f(comp_self): @@ -191,10 +191,10 @@ class ClockClassTestCase(unittest.TestCase): def test_create_user_attributes(self): def f(comp_self): - return comp_self._create_clock_class(user_attributes={'salut': 23}) + return comp_self._create_clock_class(user_attributes={"salut": 23}) cc = run_in_component_init(f) - self.assertEqual(cc.user_attributes, {'salut': 23}) + self.assertEqual(cc.user_attributes, {"salut": 23}) self.assertIs(type(cc.user_attributes), bt2_value.MapValue) def test_create_invalid_user_attributes(self): @@ -218,7 +218,7 @@ class ClockSnapshotTestCase(unittest.TestCase): def setUp(self): def f(comp_self): cc = comp_self._create_clock_class( - 1000, 'my_cc', offset=bt2.ClockClassOffset(45, 354) + 1000, "my_cc", offset=bt2.ClockClassOffset(45, 354) ) tc = comp_self._create_trace_class() @@ -227,7 +227,7 @@ class ClockSnapshotTestCase(unittest.TestCase): _cc, _tc = run_in_component_init(f) _trace = _tc() _sc = _tc.create_stream_class(default_clock_class=_cc) - _ec = _sc.create_event_class(name='salut') + _ec = _sc.create_event_class(name="salut") _stream = _trace.create_stream(_sc) self._stream = _stream self._ec = _ec @@ -254,12 +254,12 @@ class ClockSnapshotTestCase(unittest.TestCase): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") self._graph = bt2.Graph() - self._src_comp = self._graph.add_component(MySrc, 'my_source') + self._src_comp = self._graph.add_component(MySrc, "my_source") self._msg_iter = TestOutputPortMessageIterator( - self._graph, self._src_comp.output_ports['out'] + self._graph, self._src_comp.output_ports["out"] ) for i, msg in enumerate(self._msg_iter): @@ -315,5 +315,5 @@ class ClockSnapshotTestCase(unittest.TestCase): self.assertFalse(self._msg.default_clock_snapshot <= 100) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_component.py b/tests/bindings/python/bt2/test_component.py index 137a0ddb..71808fa5 100644 --- a/tests/bindings/python/bt2/test_component.py +++ b/tests/bindings/python/bt2/test_component.py @@ -14,19 +14,19 @@ class UserComponentTestCase(unittest.TestCase): graph = bt2.Graph() if name is None: - name = 'comp' + name = "comp" return graph.add_component(comp_cls, name, logging_level=log_level) def test_name(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - self.assertEqual(comp_self.name, 'yaes') + self.assertEqual(comp_self.name, "yaes") def _user_consume(self): pass - self._create_comp(MySink, 'yaes') + self._create_comp(MySink, "yaes") def test_logging_level(self): class MySink(bt2._UserSinkComponent): @@ -36,7 +36,7 @@ class UserComponentTestCase(unittest.TestCase): def _user_consume(self): pass - self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO) + self._create_comp(MySink, "yaes", bt2.LoggingLevel.INFO) def test_graph_mip_version(self): class MySink(bt2._UserSinkComponent): @@ -46,7 +46,7 @@ class UserComponentTestCase(unittest.TestCase): def _user_consume(self): pass - self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO) + self._create_comp(MySink, "yaes", bt2.LoggingLevel.INFO) def test_class(self): class MySink(bt2._UserSinkComponent): @@ -81,7 +81,7 @@ class UserComponentTestCase(unittest.TestCase): finalized = True graph = bt2.Graph() - comp = graph.add_component(MySink, 'lel') + comp = graph.add_component(MySink, "lel") del graph del comp @@ -131,7 +131,7 @@ class GenericComponentTestCase(unittest.TestCase): graph = bt2.Graph() if name is None: - name = 'comp' + name = "comp" return graph.add_component(comp_cls, name, logging_level=log_level) @@ -140,15 +140,15 @@ class GenericComponentTestCase(unittest.TestCase): def _user_consume(self): pass - comp = self._create_comp(MySink, 'yaes') - self.assertEqual(comp.name, 'yaes') + comp = self._create_comp(MySink, "yaes") + self.assertEqual(comp.name, "yaes") def test_logging_level(self): class MySink(bt2._UserSinkComponent): def _user_consume(self): pass - comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.WARNING) + comp = self._create_comp(MySink, "yaes", bt2.LoggingLevel.WARNING) self.assertEqual(comp.logging_level, bt2.LoggingLevel.WARNING) def test_class(self): @@ -169,5 +169,5 @@ class GenericComponentTestCase(unittest.TestCase): self.assertNotEqual(comp.addr, 0) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_component_class.py b/tests/bindings/python/bt2/test_component_class.py index 08b0c02b..d944c909 100644 --- a/tests/bindings/python/bt2/test_component_class.py +++ b/tests/bindings/python/bt2/test_component_class.py @@ -81,14 +81,14 @@ class UserComponentClassTestCase(unittest.TestCase): def _user_consume(self): pass - self.assertEqual(MySink.name, 'MySink') + self.assertEqual(MySink.name, "MySink") def test_custom_name(self): - class MySink(bt2._UserSinkComponent, name='salut'): + class MySink(bt2._UserSinkComponent, name="salut"): def _user_consume(self): pass - self.assertEqual(MySink.name, 'salut') + self.assertEqual(MySink.name, "salut") def test_invalid_custom_name(self): with self.assertRaises(TypeError): @@ -112,7 +112,7 @@ class UserComponentClassTestCase(unittest.TestCase): def _user_consume(self): pass - self.assertEqual(MySink.description, 'The description.') + self.assertEqual(MySink.description, "The description.") def test_empty_description_no_lines(self): class MySink(bt2._UserSinkComponent): @@ -159,7 +159,7 @@ class UserComponentClassTestCase(unittest.TestCase): def _user_consume(self): pass - self.assertEqual(MySink.help, 'The help\ntext is\nhere.') + self.assertEqual(MySink.help, "The help\ntext is\nhere.") def test_addr(self): class MySink(bt2._UserSinkComponent): @@ -175,7 +175,7 @@ class UserComponentClassTestCase(unittest.TestCase): pass with self.assertRaises(bt2.UnknownObject): - bt2.QueryExecutor(MySink, 'obj', 23).query() + bt2.QueryExecutor(MySink, "obj", 23).query() def test_query_raises(self): class MySink(bt2._UserSinkComponent): @@ -187,7 +187,7 @@ class UserComponentClassTestCase(unittest.TestCase): raise ValueError with self.assertRaises(bt2._Error): - bt2.QueryExecutor(MySink, 'obj', 23).query() + bt2.QueryExecutor(MySink, "obj", 23).query() def test_query_wrong_return_type(self): class MySink(bt2._UserSinkComponent): @@ -199,7 +199,7 @@ class UserComponentClassTestCase(unittest.TestCase): return ... with self.assertRaises(bt2._Error): - bt2.QueryExecutor(MySink, 'obj', 23).query() + bt2.QueryExecutor(MySink, "obj", 23).query() def test_query_params_none(self): class MySink(bt2._UserSinkComponent): @@ -214,7 +214,7 @@ class UserComponentClassTestCase(unittest.TestCase): query_params = None params = None - res = bt2.QueryExecutor(MySink, 'obj', params).query() + res = bt2.QueryExecutor(MySink, "obj", params).query() self.assertEqual(query_params, params) self.assertIsNone(res) del query_params @@ -230,7 +230,7 @@ class UserComponentClassTestCase(unittest.TestCase): query_log_level = priv_query_exec.logging_level query_log_level = None - query_exec = bt2.QueryExecutor(MySink, 'obj', None) + query_exec = bt2.QueryExecutor(MySink, "obj", None) query_exec.logging_level = bt2.LoggingLevel.WARNING query_exec.query() self.assertEqual(query_log_level, bt2.LoggingLevel.WARNING) @@ -245,7 +245,7 @@ class UserComponentClassTestCase(unittest.TestCase): def _user_query(priv_query_exec, obj, params, method_obj): return - res = bt2.QueryExecutor(MySink, 'obj', None).query() + res = bt2.QueryExecutor(MySink, "obj", None).query() self.assertIsNone(res) def test_query_simple(self): @@ -260,8 +260,8 @@ class UserComponentClassTestCase(unittest.TestCase): return 17.5 query_params = None - params = ['coucou', 23, None] - res = bt2.QueryExecutor(MySink, 'obj', params).query() + params = ["coucou", 23, None] + res = bt2.QueryExecutor(MySink, "obj", params).query() self.assertEqual(query_params, params) self.assertEqual(res, 17.5) del query_params @@ -275,18 +275,18 @@ class UserComponentClassTestCase(unittest.TestCase): def _user_query(cls, priv_query_exec, obj, params, method_obj): nonlocal query_params query_params = params - return {'null': None, 'bt2': 'BT2'} + return {"null": None, "bt2": "BT2"} query_params = None params = { - 'array': ['coucou', 23, None], - 'other_map': {'yes': 'yeah', '19': 19, 'minus 1.5': -1.5}, - 'null': None, + "array": ["coucou", 23, None], + "other_map": {"yes": "yeah", "19": 19, "minus 1.5": -1.5}, + "null": None, } - res = bt2.QueryExecutor(MySink, 'obj', params).query() + res = bt2.QueryExecutor(MySink, "obj", params).query() self.assertEqual(query_params, params) - self.assertEqual(res, {'null': None, 'bt2': 'BT2'}) + self.assertEqual(res, {"null": None, "bt2": "BT2"}) del query_params def test_eq(self): @@ -315,7 +315,7 @@ class ComponentClassTestCase(unittest.TestCase): self._py_comp_cls = MySink graph = bt2.Graph() - comp = graph.add_component(MySink, 'salut') + comp = graph.add_component(MySink, "salut") self._comp_cls = comp.cls self.assertIs(type(self._comp_cls), bt2._SinkComponentClassConst) @@ -324,13 +324,13 @@ class ComponentClassTestCase(unittest.TestCase): del self._comp_cls def test_description(self): - self.assertEqual(self._comp_cls.description, 'The description.') + self.assertEqual(self._comp_cls.description, "The description.") def test_help(self): - self.assertEqual(self._comp_cls.help, 'The help.') + self.assertEqual(self._comp_cls.help, "The help.") def test_name(self): - self.assertEqual(self._comp_cls.name, 'MySink') + self.assertEqual(self._comp_cls.name, "MySink") def test_addr(self): self.assertIsInstance(self._comp_cls.addr, int) @@ -345,11 +345,11 @@ class ComponentClassTestCase(unittest.TestCase): def test_query(self): res = bt2.QueryExecutor( - self._comp_cls, 'an object', {'yes': 'no', 'book': -17} + self._comp_cls, "an object", {"yes": "no", "book": -17} ).query() - expected = ['an object', {'yes': 'no', 'book': -17}, 23] + expected = ["an object", {"yes": "no", "book": -17}, 23] self.assertEqual(res, expected) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_component_descriptor.py b/tests/bindings/python/bt2/test_component_descriptor.py index 45fc84d6..818b245e 100644 --- a/tests/bindings/python/bt2/test_component_descriptor.py +++ b/tests/bindings/python/bt2/test_component_descriptor.py @@ -15,12 +15,12 @@ class _DummySink(bt2._UserSinkComponent): class ComponentDescriptorTestCase(unittest.TestCase): def setUp(self): self._obj = object() - self._comp_descr = bt2.ComponentDescriptor(_DummySink, {'zoom': -23}, self._obj) + self._comp_descr = bt2.ComponentDescriptor(_DummySink, {"zoom": -23}, self._obj) def _get_comp_cls_from_plugin(self): - plugin = bt2.find_plugin('text', find_in_user_dir=False, find_in_sys_dir=False) + plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False) assert plugin is not None - cc = plugin.source_component_classes['dmesg'] + cc = plugin.source_component_classes["dmesg"] assert cc is not None return cc @@ -49,11 +49,11 @@ class ComponentDescriptorTestCase(unittest.TestCase): self.assertIs(self._comp_descr.component_class, _DummySink) def test_attr_params(self): - self.assertEqual(self._comp_descr.params, {'zoom': -23}) + self.assertEqual(self._comp_descr.params, {"zoom": -23}) def test_attr_obj(self): self.assertIs(self._comp_descr.obj, self._obj) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_connection.py b/tests/bindings/python/bt2/test_connection.py index e2f7f010..7ec6bb01 100644 --- a/tests/bindings/python/bt2/test_connection.py +++ b/tests/bindings/python/bt2/test_connection.py @@ -15,19 +15,19 @@ class ConnectionTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop graph = bt2.Graph() - src = graph.add_component(MySource, 'src') - sink = graph.add_component(MySink, 'sink') - conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = graph.add_component(MySource, "src") + sink = graph.add_component(MySink, "sink") + conn = graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) self.assertIs(type(conn), bt2_connection._ConnectionConst) def test_downstream_port(self): @@ -35,20 +35,20 @@ class ConnectionTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop graph = bt2.Graph() - src = graph.add_component(MySource, 'src') - sink = graph.add_component(MySink, 'sink') - conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) - self.assertEqual(conn.downstream_port.addr, sink.input_ports['in'].addr) + src = graph.add_component(MySource, "src") + sink = graph.add_component(MySink, "sink") + conn = graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) + self.assertEqual(conn.downstream_port.addr, sink.input_ports["in"].addr) self.assertIs(type(conn), bt2_connection._ConnectionConst) self.assertIs(type(conn.downstream_port), bt2_port._InputPortConst) @@ -57,22 +57,22 @@ class ConnectionTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop graph = bt2.Graph() - src = graph.add_component(MySource, 'src') - sink = graph.add_component(MySink, 'sink') - conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) - self.assertEqual(conn.upstream_port.addr, src.output_ports['out'].addr) + src = graph.add_component(MySource, "src") + sink = graph.add_component(MySink, "sink") + conn = graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) + self.assertEqual(conn.upstream_port.addr, src.output_ports["out"].addr) self.assertIs(type(conn.upstream_port), bt2_port._OutputPortConst) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_error.py b/tests/bindings/python/bt2/test_error.py index 1126ca70..b4b90ad5 100644 --- a/tests/bindings/python/bt2/test_error.py +++ b/tests/bindings/python/bt2/test_error.py @@ -10,26 +10,26 @@ import unittest class FailingIter(bt2._UserMessageIterator): def __next__(self): - raise ValueError('User message iterator is failing') + raise ValueError("User message iterator is failing") class SourceWithFailingIter( bt2._UserSourceComponent, message_iterator_class=FailingIter ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class SourceWithFailingInit( bt2._UserSourceComponent, message_iterator_class=FailingIter ): def __init__(self, config, params, obj): - raise ValueError('Source is failing') + raise ValueError("Source is failing") class WorkingSink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._in = self._add_input_port('in') + self._in = self._add_input_port("in") def _user_graph_is_configured(self): self._iter = self._create_message_iterator(self._in) @@ -40,7 +40,7 @@ class WorkingSink(bt2._UserSinkComponent): class SinkWithExceptionChaining(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._in = self._add_input_port('in') + self._in = self._add_input_port("in") def _user_graph_is_configured(self): self._iter = self._create_message_iterator(self._in) @@ -49,7 +49,7 @@ class SinkWithExceptionChaining(bt2._UserSinkComponent): try: next(self._iter) except bt2._Error as e: - raise ValueError('oops') from e + raise ValueError("oops") from e class SinkWithFailingQuery(bt2._UserSinkComponent): @@ -58,16 +58,16 @@ class SinkWithFailingQuery(bt2._UserSinkComponent): @staticmethod def _user_query(priv_executor, obj, params, method_obj): - raise ValueError('Query is failing') + raise ValueError("Query is failing") class ErrorTestCase(unittest.TestCase): def _run_failing_graph(self, source_cc, sink_cc): with self.assertRaises(bt2._Error) as ctx: graph = bt2.Graph() - src = graph.add_component(source_cc, 'src') - snk = graph.add_component(sink_cc, 'snk') - graph.connect_ports(src.output_ports['out'], snk.input_ports['in']) + src = graph.add_component(source_cc, "src") + snk = graph.add_component(sink_cc, "snk") + graph.connect_ports(src.output_ports["out"], snk.input_ports["in"]) graph.run() return ctx.exception @@ -123,20 +123,20 @@ class ErrorTestCase(unittest.TestCase): self.assertEqual(len(exc), 5) self.assertIsInstance(exc[0], bt2._MessageIteratorErrorCause) - self.assertEqual(exc[0].component_class_name, 'SourceWithFailingIter') - self.assertIn('ValueError: User message iterator is failing', exc[0].message) + self.assertEqual(exc[0].component_class_name, "SourceWithFailingIter") + self.assertIn("ValueError: User message iterator is failing", exc[0].message) self.assertIsInstance(exc[1], bt2._ErrorCause) self.assertIsInstance(exc[2], bt2._ComponentErrorCause) - self.assertEqual(exc[2].component_class_name, 'SinkWithExceptionChaining') + self.assertEqual(exc[2].component_class_name, "SinkWithExceptionChaining") self.assertIn( - 'unexpected error: cannot advance the message iterator', exc[2].message + "unexpected error: cannot advance the message iterator", exc[2].message ) self.assertIsInstance(exc[3], bt2._ComponentErrorCause) - self.assertEqual(exc[3].component_class_name, 'SinkWithExceptionChaining') - self.assertIn('ValueError: oops', exc[3].message) + self.assertEqual(exc[3].component_class_name, "SinkWithExceptionChaining") + self.assertIn("ValueError: oops", exc[3].message) self.assertIsInstance(exc[4], bt2._ErrorCause) @@ -157,14 +157,14 @@ class ErrorTestCase(unittest.TestCase): self.assertIs(type(cause), bt2._ComponentErrorCause) self._common_cause_tests(cause) - self.assertIn('Source is failing', cause.message) - self.assertEqual(cause.component_name, 'src') + self.assertIn("Source is failing", cause.message) + self.assertEqual(cause.component_name, "src") self.assertEqual(cause.component_class_type, bt2.ComponentClassType.SOURCE) - self.assertEqual(cause.component_class_name, 'SourceWithFailingInit') + self.assertEqual(cause.component_class_name, "SourceWithFailingInit") self.assertIsNone(cause.plugin_name) def test_component_class_error_cause(self): - q = bt2.QueryExecutor(SinkWithFailingQuery, 'hello') + q = bt2.QueryExecutor(SinkWithFailingQuery, "hello") with self.assertRaises(bt2._Error) as ctx: q.query() @@ -173,10 +173,10 @@ class ErrorTestCase(unittest.TestCase): self.assertIs(type(cause), bt2._ComponentClassErrorCause) self._common_cause_tests(cause) - self.assertIn('Query is failing', cause.message) + self.assertIn("Query is failing", cause.message) self.assertEqual(cause.component_class_type, bt2.ComponentClassType.SINK) - self.assertEqual(cause.component_class_name, 'SinkWithFailingQuery') + self.assertEqual(cause.component_class_name, "SinkWithFailingQuery") self.assertIsNone(cause.plugin_name) def test_message_iterator_error_cause(self): @@ -185,11 +185,11 @@ class ErrorTestCase(unittest.TestCase): self.assertIs(type(cause), bt2._MessageIteratorErrorCause) self._common_cause_tests(cause) - self.assertIn('User message iterator is failing', cause.message) - self.assertEqual(cause.component_name, 'src') - self.assertEqual(cause.component_output_port_name, 'out') + self.assertIn("User message iterator is failing", cause.message) + self.assertEqual(cause.component_name, "src") + self.assertEqual(cause.component_output_port_name, "out") self.assertEqual(cause.component_class_type, bt2.ComponentClassType.SOURCE) - self.assertEqual(cause.component_class_name, 'SourceWithFailingIter') + self.assertEqual(cause.component_class_name, "SourceWithFailingIter") self.assertIsNone(cause.plugin_name) def test_str(self): @@ -199,8 +199,8 @@ class ErrorTestCase(unittest.TestCase): exc = self._run_failing_graph(SourceWithFailingIter, SinkWithExceptionChaining) s = str(exc) self.assertIn("[src (out): 'source.SourceWithFailingIter']", s) - self.assertIn('ValueError: oops', s) + self.assertIn("ValueError: oops", s) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_event.py b/tests/bindings/python/bt2/test_event.py index 979579b0..970b7c22 100644 --- a/tests/bindings/python/bt2/test_event.py +++ b/tests/bindings/python/bt2/test_event.py @@ -69,7 +69,7 @@ class EventTestCase(unittest.TestCase): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") tc = self._create_trace_class() clock_class = None @@ -81,9 +81,9 @@ class EventTestCase(unittest.TestCase): if with_cc: cc = tc.create_structure_field_class() cc += [ - ('cpu_id', tc.create_signed_integer_field_class(8)), - ('stuff', tc.create_double_precision_real_field_class()), - ('gnu', tc.create_string_field_class()), + ("cpu_id", tc.create_signed_integer_field_class(8)), + ("stuff", tc.create_double_precision_real_field_class()), + ("gnu", tc.create_string_field_class()), ] # packet context (stream-class-defined) @@ -92,9 +92,9 @@ class EventTestCase(unittest.TestCase): if with_packet: pc = tc.create_structure_field_class() pc += [ - ('something', tc.create_unsigned_integer_field_class(8)), + ("something", tc.create_unsigned_integer_field_class(8)), ( - 'something_else', + "something_else", tc.create_double_precision_real_field_class(), ), ] @@ -111,8 +111,8 @@ class EventTestCase(unittest.TestCase): if with_sc: sc = tc.create_structure_field_class() sc += [ - ('ant', tc.create_signed_integer_field_class(16)), - ('msg', tc.create_string_field_class()), + ("ant", tc.create_signed_integer_field_class(16)), + ("msg", tc.create_string_field_class()), ] # event payload @@ -120,13 +120,13 @@ class EventTestCase(unittest.TestCase): if with_ep: ep = tc.create_structure_field_class() ep += [ - ('giraffe', tc.create_signed_integer_field_class(32)), - ('gnu', tc.create_signed_integer_field_class(8)), - ('mosquito', tc.create_signed_integer_field_class(8)), + ("giraffe", tc.create_signed_integer_field_class(32)), + ("gnu", tc.create_signed_integer_field_class(8)), + ("mosquito", tc.create_signed_integer_field_class(8)), ] event_class = stream_class.create_event_class( - name='garou', + name="garou", specific_context_field_class=sc, payload_field_class=ep, ) @@ -149,9 +149,9 @@ class EventTestCase(unittest.TestCase): test_obj = self self._graph = bt2.Graph() - self._src_comp = self._graph.add_component(MySrc, 'my_source') + self._src_comp = self._graph.add_component(MySrc, "my_source") self._msg_iter = TestOutputPortMessageIterator( - self._graph, self._src_comp.output_ports['out'] + self._graph, self._src_comp.output_ports["out"] ) for msg in self._msg_iter: @@ -178,17 +178,17 @@ class EventTestCase(unittest.TestCase): def test_const_get_common_context_field(self): def event_fields_config(event): - event.common_context_field['cpu_id'] = 1 - event.common_context_field['stuff'] = 13.194 - event.common_context_field['gnu'] = 'salut' + event.common_context_field["cpu_id"] = 1 + event.common_context_field["stuff"] = 13.194 + event.common_context_field["gnu"] = "salut" msg = self._create_test_const_event_message( event_fields_config=event_fields_config, with_cc=True ) - self.assertEqual(msg.event.common_context_field['cpu_id'], 1) - self.assertEqual(msg.event.common_context_field['stuff'], 13.194) - self.assertEqual(msg.event.common_context_field['gnu'], 'salut') + self.assertEqual(msg.event.common_context_field["cpu_id"], 1) + self.assertEqual(msg.event.common_context_field["stuff"], 13.194) + self.assertEqual(msg.event.common_context_field["gnu"], "salut") self.assertIs( type(msg.event.common_context_field), bt2_field._StructureFieldConst ) @@ -203,15 +203,15 @@ class EventTestCase(unittest.TestCase): def test_const_get_specific_context_field(self): def event_fields_config(event): - event.specific_context_field['ant'] = -1 - event.specific_context_field['msg'] = 'hellooo' + event.specific_context_field["ant"] = -1 + event.specific_context_field["msg"] = "hellooo" msg = self._create_test_const_event_message( event_fields_config=event_fields_config, with_sc=True ) - self.assertEqual(msg.event.specific_context_field['ant'], -1) - self.assertEqual(msg.event.specific_context_field['msg'], 'hellooo') + self.assertEqual(msg.event.specific_context_field["ant"], -1) + self.assertEqual(msg.event.specific_context_field["msg"], "hellooo") self.assertIs( type(msg.event.specific_context_field), bt2_field._StructureFieldConst ) @@ -226,17 +226,17 @@ class EventTestCase(unittest.TestCase): def test_const_get_event_payload_field(self): def event_fields_config(event): - event.payload_field['giraffe'] = 1 - event.payload_field['gnu'] = 23 - event.payload_field['mosquito'] = 42 + event.payload_field["giraffe"] = 1 + event.payload_field["gnu"] = 23 + event.payload_field["mosquito"] = 42 msg = self._create_test_const_event_message( event_fields_config=event_fields_config, with_ep=True ) - self.assertEqual(msg.event.payload_field['giraffe'], 1) - self.assertEqual(msg.event.payload_field['gnu'], 23) - self.assertEqual(msg.event.payload_field['mosquito'], 42) + self.assertEqual(msg.event.payload_field["giraffe"], 1) + self.assertEqual(msg.event.payload_field["gnu"], 23) + self.assertEqual(msg.event.payload_field["mosquito"], 42) self.assertIs(type(msg.event.payload_field), bt2_field._StructureFieldConst) def test_attr_payload_field(self): @@ -264,7 +264,7 @@ class EventTestCase(unittest.TestCase): def test_const_no_clock_value(self): msg = self._create_test_const_event_message(with_clockclass=False) with self.assertRaisesRegex( - ValueError, 'stream class has no default clock class' + ValueError, "stream class has no default clock class" ): msg.default_clock_snapshot @@ -279,23 +279,23 @@ class EventTestCase(unittest.TestCase): @staticmethod def _event_payload_fields_config(event): - event.payload_field['giraffe'] = 1 - event.payload_field['gnu'] = 23 - event.payload_field['mosquito'] = 42 + event.payload_field["giraffe"] = 1 + event.payload_field["gnu"] = 23 + event.payload_field["mosquito"] = 42 @staticmethod def _event_fields_config(event): EventTestCase._event_payload_fields_config(event) - event.specific_context_field['ant'] = -1 - event.specific_context_field['msg'] = 'hellooo' - event.common_context_field['cpu_id'] = 1 - event.common_context_field['stuff'] = 13.194 - event.common_context_field['gnu'] = 'salut' + event.specific_context_field["ant"] = -1 + event.specific_context_field["msg"] = "hellooo" + event.common_context_field["cpu_id"] = 1 + event.common_context_field["stuff"] = 13.194 + event.common_context_field["gnu"] = "salut" @staticmethod def _packet_fields_config(packet): - packet.context_field['something'] = 154 - packet.context_field['something_else'] = 17.2 + packet.context_field["something"] = 154 + packet.context_field["something_else"] = 17.2 def test_const_getitem(self): msg = self._create_test_const_event_message( @@ -309,24 +309,24 @@ class EventTestCase(unittest.TestCase): ev = msg.event # Test event fields - self.assertEqual(ev['giraffe'], 1) - self.assertIs(type(ev['giraffe']), bt2_field._SignedIntegerFieldConst) - self.assertEqual(ev['gnu'], 23) - self.assertEqual(ev['mosquito'], 42) - self.assertEqual(ev['ant'], -1) - self.assertIs(type(ev['ant']), bt2_field._SignedIntegerFieldConst) - self.assertEqual(ev['msg'], 'hellooo') - self.assertEqual(ev['cpu_id'], 1) - self.assertIs(type(ev['cpu_id']), bt2_field._SignedIntegerFieldConst) - self.assertEqual(ev['stuff'], 13.194) + self.assertEqual(ev["giraffe"], 1) + self.assertIs(type(ev["giraffe"]), bt2_field._SignedIntegerFieldConst) + self.assertEqual(ev["gnu"], 23) + self.assertEqual(ev["mosquito"], 42) + self.assertEqual(ev["ant"], -1) + self.assertIs(type(ev["ant"]), bt2_field._SignedIntegerFieldConst) + self.assertEqual(ev["msg"], "hellooo") + self.assertEqual(ev["cpu_id"], 1) + self.assertIs(type(ev["cpu_id"]), bt2_field._SignedIntegerFieldConst) + self.assertEqual(ev["stuff"], 13.194) # Test packet fields - self.assertEqual(ev['something'], 154) - self.assertIs(type(ev['something']), bt2_field._UnsignedIntegerFieldConst) - self.assertEqual(ev['something_else'], 17.2) + self.assertEqual(ev["something"], 154) + self.assertIs(type(ev["something"]), bt2_field._UnsignedIntegerFieldConst) + self.assertEqual(ev["something_else"], 17.2) with self.assertRaises(KeyError): - ev['yes'] + ev["yes"] def test_const_getitem_no_packet(self): msg = self._create_test_const_event_message( @@ -336,19 +336,19 @@ class EventTestCase(unittest.TestCase): ev = msg.event with self.assertRaises(KeyError): - ev['yes'] + ev["yes"] def test_getitem(self): msg = utils.get_event_message() ev = msg.event - self.assertEqual(ev['giraffe'], 1) - self.assertIs(type(ev['giraffe']), bt2_field._SignedIntegerField) - self.assertEqual(ev['ant'], -1) - self.assertIs(type(ev['ant']), bt2_field._SignedIntegerField) - self.assertEqual(ev['cpu_id'], 1) - self.assertIs(type(ev['cpu_id']), bt2_field._SignedIntegerField) - self.assertEqual(ev['something'], 154) - self.assertIs(type(ev['something']), bt2_field._UnsignedIntegerField) + self.assertEqual(ev["giraffe"], 1) + self.assertIs(type(ev["giraffe"]), bt2_field._SignedIntegerField) + self.assertEqual(ev["ant"], -1) + self.assertIs(type(ev["ant"]), bt2_field._SignedIntegerField) + self.assertEqual(ev["cpu_id"], 1) + self.assertIs(type(ev["cpu_id"]), bt2_field._SignedIntegerField) + self.assertEqual(ev["something"], 154) + self.assertIs(type(ev["something"]), bt2_field._UnsignedIntegerField) def test_iter_full(self): msg = self._create_test_const_event_message( @@ -361,18 +361,18 @@ class EventTestCase(unittest.TestCase): ) expected_field_names = [ # payload - 'giraffe', - 'gnu', - 'mosquito', + "giraffe", + "gnu", + "mosquito", # specific context - 'ant', - 'msg', + "ant", + "msg", # common context - 'cpu_id', - 'stuff', + "cpu_id", + "stuff", # packet context - 'something', - 'something_else', + "something", + "something_else", ] self.assertEqual(list(msg.event), expected_field_names) @@ -383,9 +383,9 @@ class EventTestCase(unittest.TestCase): ) expected_field_names = [ # payload - 'giraffe', - 'gnu', - 'mosquito', + "giraffe", + "gnu", + "mosquito", ] self.assertEqual(list(msg.event), expected_field_names) @@ -419,24 +419,24 @@ class EventTestCase(unittest.TestCase): ) field_names = [ # payload - 'giraffe', - 'gnu', - 'mosquito', + "giraffe", + "gnu", + "mosquito", # specific context - 'ant', - 'msg', + "ant", + "msg", # common context - 'cpu_id', - 'stuff', + "cpu_id", + "stuff", # packet context - 'something', - 'something_else', + "something", + "something_else", ] for field_name in field_names: self.assertTrue(field_name in msg.event) - self.assertFalse('lol' in msg.event) + self.assertFalse("lol" in msg.event) def test_in_payload_only(self): msg = self._create_test_const_event_message( @@ -445,15 +445,15 @@ class EventTestCase(unittest.TestCase): with_ep=True, ) field_names = [ - 'giraffe', - 'gnu', - 'mosquito', + "giraffe", + "gnu", + "mosquito", ] for field_name in field_names: self.assertTrue(field_name in msg.event) - self.assertFalse('lol' in msg.event) + self.assertFalse("lol" in msg.event) if __name__ == "__main__": diff --git a/tests/bindings/python/bt2/test_event_class.py b/tests/bindings/python/bt2/test_event_class.py index 8b49ffb7..ae6f0981 100644 --- a/tests/bindings/python/bt2/test_event_class.py +++ b/tests/bindings/python/bt2/test_event_class.py @@ -38,11 +38,11 @@ def _create_const_event_class(tc, stream_class): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out', params) + self._add_output_port("out", params) graph = bt2.Graph() - src_comp = graph.add_component(MySrc, 'my_source', None) - msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports['out']) + src_comp = graph.add_component(MySrc, "my_source", None) + msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports["out"]) # Ignore first message, stream beginning _ = next(msg_iter) @@ -57,13 +57,13 @@ class EventClassTestCase(unittest.TestCase): self._tc = get_default_trace_class() self._context_fc = self._tc.create_structure_field_class() - self._context_fc.append_member('allo', self._tc.create_string_field_class()) + self._context_fc.append_member("allo", self._tc.create_string_field_class()) self._context_fc.append_member( - 'zola', self._tc.create_signed_integer_field_class(18) + "zola", self._tc.create_signed_integer_field_class(18) ) self._payload_fc = self._tc.create_structure_field_class() - self._payload_fc.append_member('zoom', self._tc.create_string_field_class()) + self._payload_fc.append_member("zoom", self._tc.create_string_field_class()) self._stream_class = self._tc.create_stream_class( assigns_automatic_event_class_id=True @@ -73,7 +73,7 @@ class EventClassTestCase(unittest.TestCase): ec = self._stream_class.create_event_class() self.assertIs(type(ec), bt2_event_class._EventClass) - self.assertIsNone(ec.name, 'my_event') + self.assertIsNone(ec.name, "my_event") self.assertTrue(type(ec.id), int) self.assertIsNone(ec.specific_context_field_class) self.assertIsNone(ec.payload_field_class) @@ -84,7 +84,7 @@ class EventClassTestCase(unittest.TestCase): def test_create_invalid_id(self): sc = self._tc.create_stream_class(assigns_automatic_event_class_id=False) with self.assertRaises(TypeError): - sc.create_event_class(id='lel') + sc.create_event_class(id="lel") self.assertEqual(len(sc), 0) @@ -105,7 +105,7 @@ class EventClassTestCase(unittest.TestCase): def test_create_invalid_specific_context_field_class(self): with self.assertRaises(TypeError): - self._stream_class.create_event_class(specific_context_field_class='lel') + self._stream_class.create_event_class(specific_context_field_class="lel") self.assertEqual(len(self._stream_class), 0) @@ -126,13 +126,13 @@ class EventClassTestCase(unittest.TestCase): def test_create_invalid_payload_field_class(self): with self.assertRaises(TypeError): - self._stream_class.create_event_class(payload_field_class='lel') + self._stream_class.create_event_class(payload_field_class="lel") self.assertEqual(len(self._stream_class), 0) def test_create_name(self): - ec = self._stream_class.create_event_class(name='viande à chien') - self.assertEqual(ec.name, 'viande à chien') + ec = self._stream_class.create_event_class(name="viande à chien") + self.assertEqual(ec.name, "viande à chien") def test_create_invalid_name(self): with self.assertRaises(TypeError): @@ -141,8 +141,8 @@ class EventClassTestCase(unittest.TestCase): self.assertEqual(len(self._stream_class), 0) def test_emf_uri(self): - ec = self._stream_class.create_event_class(emf_uri='salut') - self.assertEqual(ec.emf_uri, 'salut') + ec = self._stream_class.create_event_class(emf_uri="salut") + self.assertEqual(ec.emf_uri, "salut") def test_create_invalid_emf_uri(self): with self.assertRaises(TypeError): @@ -158,13 +158,13 @@ class EventClassTestCase(unittest.TestCase): def test_create_invalid_log_level(self): with self.assertRaises(ValueError): - self._stream_class.create_event_class(log_level='zoom') + self._stream_class.create_event_class(log_level="zoom") self.assertEqual(len(self._stream_class), 0) def test_create_user_attributes(self): - ec = self._stream_class.create_event_class(user_attributes={'salut': 23}) - self.assertEqual(ec.user_attributes, {'salut': 23}) + ec = self._stream_class.create_event_class(user_attributes={"salut": 23}) + self.assertEqual(ec.user_attributes, {"salut": 23}) self.assertIs(type(ec.user_attributes), bt2_value.MapValue) def test_const_create_user_attributes(self): @@ -193,5 +193,5 @@ class EventClassTestCase(unittest.TestCase): self.assertIs(type(ec_const.stream_class), bt2_stream_class._StreamClassConst) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_field.py b/tests/bindings/python/bt2/test_field.py index 6815715e..e7517941 100644 --- a/tests/bindings/python/bt2/test_field.py +++ b/tests/bindings/python/bt2/test_field.py @@ -44,7 +44,7 @@ def _create_stream(tc, ctx_field_classes): def _create_field(tc, field_class): - field_name = 'field' + field_name = "field" stream = _create_stream(tc, [(field_name, field_class)]) packet = stream.create_packet() return packet.context_field[field_name] @@ -57,7 +57,7 @@ def _create_field(tc, field_class): def _create_string_field(tc): - field_name = 'string_field' + field_name = "string_field" stream = _create_stream(tc, [(field_name, tc.create_string_field_class())]) packet = stream.create_packet() return packet.context_field[field_name] @@ -73,7 +73,7 @@ def _create_string_field(tc): def _create_int_array_field(tc, length): elem_fc = tc.create_signed_integer_field_class(32) fc = tc.create_static_array_field_class(elem_fc, length) - field_name = 'int_array' + field_name = "int_array" stream = _create_stream(tc, [(field_name, fc)]) packet = stream.create_packet() return packet.context_field[field_name] @@ -90,8 +90,8 @@ def _create_dynamic_array(tc): elem_fc = tc.create_signed_integer_field_class(32) len_fc = tc.create_signed_integer_field_class(32) fc = tc.create_dynamic_array_field_class(elem_fc) - field_name = 'int_dyn_array' - stream = _create_stream(tc, [('thelength', len_fc), (field_name, fc)]) + field_name = "int_dyn_array" + stream = _create_stream(tc, [("thelength", len_fc), (field_name, fc)]) packet = stream.create_packet() packet.context_field[field_name].length = 3 return packet.context_field[field_name] @@ -107,7 +107,7 @@ def _create_dynamic_array(tc): def _create_struct_array_field(tc, length): elem_fc = tc.create_structure_field_class() fc = tc.create_static_array_field_class(elem_fc, length) - field_name = 'struct_array' + field_name = "struct_array" stream = _create_stream(tc, [(field_name, fc)]) packet = stream.create_packet() return packet.context_field[field_name] @@ -126,7 +126,7 @@ class BitArrayFieldTestCase(unittest.TestCase): def test_assign_invalid_type(self): with self.assertRaises(TypeError): - self._def.value_as_integer = 'onze' + self._def.value_as_integer = "onze" def test_assign(self): self._def.value_as_integer = 199 @@ -620,8 +620,8 @@ class _TestNumericField: def test_const_hash_dict(self): my_dict = {} - my_dict[self._def_const] = 'my_value' - self.assertEqual(my_dict[self._def_value], 'my_value') + my_dict[self._def_const] = "my_value" + self.assertEqual(my_dict[self._def_value], "my_value") def test_eq_none(self): # Ignore this lint error: @@ -642,36 +642,36 @@ class _TestNumericField: # Each entry is a pair of binary operator name (used as part of the # created testing method's name) and operator function. _BINOPS = ( - ('lt', operator.lt), - ('le', operator.le), - ('eq', operator.eq), - ('ne', operator.ne), - ('ge', operator.ge), - ('gt', operator.gt), - ('add', operator.add), - ('radd', lambda a, b: operator.add(b, a)), - ('and', operator.and_), - ('rand', lambda a, b: operator.and_(b, a)), - ('floordiv', operator.floordiv), - ('rfloordiv', lambda a, b: operator.floordiv(b, a)), - ('lshift', operator.lshift), - ('rlshift', lambda a, b: operator.lshift(b, a)), - ('mod', operator.mod), - ('rmod', lambda a, b: operator.mod(b, a)), - ('mul', operator.mul), - ('rmul', lambda a, b: operator.mul(b, a)), - ('or', operator.or_), - ('ror', lambda a, b: operator.or_(b, a)), - ('pow', operator.pow), - ('rpow', lambda a, b: operator.pow(b, a)), - ('rshift', operator.rshift), - ('rrshift', lambda a, b: operator.rshift(b, a)), - ('sub', operator.sub), - ('rsub', lambda a, b: operator.sub(b, a)), - ('truediv', operator.truediv), - ('rtruediv', lambda a, b: operator.truediv(b, a)), - ('xor', operator.xor), - ('rxor', lambda a, b: operator.xor(b, a)), + ("lt", operator.lt), + ("le", operator.le), + ("eq", operator.eq), + ("ne", operator.ne), + ("ge", operator.ge), + ("gt", operator.gt), + ("add", operator.add), + ("radd", lambda a, b: operator.add(b, a)), + ("and", operator.and_), + ("rand", lambda a, b: operator.and_(b, a)), + ("floordiv", operator.floordiv), + ("rfloordiv", lambda a, b: operator.floordiv(b, a)), + ("lshift", operator.lshift), + ("rlshift", lambda a, b: operator.lshift(b, a)), + ("mod", operator.mod), + ("rmod", lambda a, b: operator.mod(b, a)), + ("mul", operator.mul), + ("rmul", lambda a, b: operator.mul(b, a)), + ("or", operator.or_), + ("ror", lambda a, b: operator.or_(b, a)), + ("pow", operator.pow), + ("rpow", lambda a, b: operator.pow(b, a)), + ("rshift", operator.rshift), + ("rrshift", lambda a, b: operator.rshift(b, a)), + ("sub", operator.sub), + ("rsub", lambda a, b: operator.sub(b, a)), + ("truediv", operator.truediv), + ("rtruediv", lambda a, b: operator.truediv(b, a)), + ("xor", operator.xor), + ("rxor", lambda a, b: operator.xor(b, a)), ) @@ -681,18 +681,18 @@ _BINOPS = ( # Each entry is a pair of unary operator name (used as part of the # created testing method's name) and operator function. _UNARYOPS = ( - ('neg', operator.neg), - ('pos', operator.pos), - ('abs', operator.abs), - ('invert', operator.invert), - ('round', round), - ('round_0', partial(round, ndigits=0)), - ('round_1', partial(round, ndigits=1)), - ('round_2', partial(round, ndigits=2)), - ('round_3', partial(round, ndigits=3)), - ('ceil', math.ceil), - ('floor', math.floor), - ('trunc', math.trunc), + ("neg", operator.neg), + ("pos", operator.pos), + ("abs", operator.abs), + ("invert", operator.invert), + ("round", round), + ("round_0", partial(round, ndigits=0)), + ("round_1", partial(round, ndigits=1)), + ("round_2", partial(round, ndigits=2)), + ("round_3", partial(round, ndigits=3)), + ("ceil", math.ceil), + ("floor", math.floor), + ("trunc", math.trunc), ) @@ -712,395 +712,395 @@ _UNARYOPS = ( # method, for each unary operator in the _UNARYOPS tuple. def _inject_numeric_testing_methods(cls): def test_binop_name(suffix): - return 'test_binop_{}_{}'.format(name, suffix) + return "test_binop_{}_{}".format(name, suffix) def test_unaryop_name(suffix): - return 'test_unaryop_{}_{}'.format(name, suffix) + return "test_unaryop_{}_{}".format(name, suffix) # inject testing methods for each binary operation for name, binop in _BINOPS: setattr( cls, - test_binop_name('unknown'), + test_binop_name("unknown"), partialmethod(_TestNumericField._test_binop_unknown, op=binop), ) setattr( cls, - test_binop_name('none'), + test_binop_name("none"), partialmethod(_TestNumericField._test_binop_none, op=binop), ) setattr( cls, - test_binop_name('type_true'), + test_binop_name("type_true"), partialmethod(_TestNumericField._test_binop_type_true, op=binop), ) setattr( cls, - test_binop_name('type_pos_int'), + test_binop_name("type_pos_int"), partialmethod(_TestNumericField._test_binop_type_pos_int, op=binop), ) setattr( cls, - test_binop_name('type_pos_vint'), + test_binop_name("type_pos_vint"), partialmethod(_TestNumericField._test_binop_type_pos_vint, op=binop), ) setattr( cls, - test_binop_name('value_true'), + test_binop_name("value_true"), partialmethod(_TestNumericField._test_binop_value_true, op=binop), ) setattr( cls, - test_binop_name('value_pos_int'), + test_binop_name("value_pos_int"), partialmethod(_TestNumericField._test_binop_value_pos_int, op=binop), ) setattr( cls, - test_binop_name('value_pos_vint'), + test_binop_name("value_pos_vint"), partialmethod(_TestNumericField._test_binop_value_pos_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_true'), + test_binop_name("lhs_addr_same_true"), partialmethod(_TestNumericField._test_binop_lhs_addr_same_true, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_int'), + test_binop_name("lhs_addr_same_pos_int"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_pos_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_vint'), + test_binop_name("lhs_addr_same_pos_vint"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_pos_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_true'), + test_binop_name("lhs_value_same_true"), partialmethod(_TestNumericField._test_binop_lhs_value_same_true, op=binop), ) setattr( cls, - test_binop_name('lhs_value_same_pos_int'), + test_binop_name("lhs_value_same_pos_int"), partialmethod( _TestNumericField._test_binop_lhs_value_same_pos_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_vint'), + test_binop_name("lhs_value_same_pos_vint"), partialmethod( _TestNumericField._test_binop_lhs_value_same_pos_vint, op=binop ), ) setattr( cls, - test_binop_name('type_neg_int'), + test_binop_name("type_neg_int"), partialmethod(_TestNumericField._test_binop_type_neg_int, op=binop), ) setattr( cls, - test_binop_name('type_neg_vint'), + test_binop_name("type_neg_vint"), partialmethod(_TestNumericField._test_binop_type_neg_vint, op=binop), ) setattr( cls, - test_binop_name('value_neg_int'), + test_binop_name("value_neg_int"), partialmethod(_TestNumericField._test_binop_value_neg_int, op=binop), ) setattr( cls, - test_binop_name('value_neg_vint'), + test_binop_name("value_neg_vint"), partialmethod(_TestNumericField._test_binop_value_neg_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_int'), + test_binop_name("lhs_addr_same_neg_int"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_neg_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_vint'), + test_binop_name("lhs_addr_same_neg_vint"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_neg_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_int'), + test_binop_name("lhs_value_same_neg_int"), partialmethod( _TestNumericField._test_binop_lhs_value_same_neg_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_vint'), + test_binop_name("lhs_value_same_neg_vint"), partialmethod( _TestNumericField._test_binop_lhs_value_same_neg_vint, op=binop ), ) setattr( cls, - test_binop_name('type_false'), + test_binop_name("type_false"), partialmethod(_TestNumericField._test_binop_type_false, op=binop), ) setattr( cls, - test_binop_name('type_zero_int'), + test_binop_name("type_zero_int"), partialmethod(_TestNumericField._test_binop_type_zero_int, op=binop), ) setattr( cls, - test_binop_name('type_zero_vint'), + test_binop_name("type_zero_vint"), partialmethod(_TestNumericField._test_binop_type_zero_vint, op=binop), ) setattr( cls, - test_binop_name('value_false'), + test_binop_name("value_false"), partialmethod(_TestNumericField._test_binop_value_false, op=binop), ) setattr( cls, - test_binop_name('value_zero_int'), + test_binop_name("value_zero_int"), partialmethod(_TestNumericField._test_binop_value_zero_int, op=binop), ) setattr( cls, - test_binop_name('value_zero_vint'), + test_binop_name("value_zero_vint"), partialmethod(_TestNumericField._test_binop_value_zero_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_false'), + test_binop_name("lhs_addr_same_false"), partialmethod(_TestNumericField._test_binop_lhs_addr_same_false, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_int'), + test_binop_name("lhs_addr_same_zero_int"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_zero_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_vint'), + test_binop_name("lhs_addr_same_zero_vint"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_zero_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_false'), + test_binop_name("lhs_value_same_false"), partialmethod(_TestNumericField._test_binop_lhs_value_same_false, op=binop), ) setattr( cls, - test_binop_name('lhs_value_same_zero_int'), + test_binop_name("lhs_value_same_zero_int"), partialmethod( _TestNumericField._test_binop_lhs_value_same_zero_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_vint'), + test_binop_name("lhs_value_same_zero_vint"), partialmethod( _TestNumericField._test_binop_lhs_value_same_zero_vint, op=binop ), ) setattr( cls, - test_binop_name('type_pos_float'), + test_binop_name("type_pos_float"), partialmethod(_TestNumericField._test_binop_type_pos_float, op=binop), ) setattr( cls, - test_binop_name('type_neg_float'), + test_binop_name("type_neg_float"), partialmethod(_TestNumericField._test_binop_type_neg_float, op=binop), ) setattr( cls, - test_binop_name('type_pos_vfloat'), + test_binop_name("type_pos_vfloat"), partialmethod(_TestNumericField._test_binop_type_pos_vfloat, op=binop), ) setattr( cls, - test_binop_name('type_neg_vfloat'), + test_binop_name("type_neg_vfloat"), partialmethod(_TestNumericField._test_binop_type_neg_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_pos_float'), + test_binop_name("value_pos_float"), partialmethod(_TestNumericField._test_binop_value_pos_float, op=binop), ) setattr( cls, - test_binop_name('value_neg_float'), + test_binop_name("value_neg_float"), partialmethod(_TestNumericField._test_binop_value_neg_float, op=binop), ) setattr( cls, - test_binop_name('value_pos_vfloat'), + test_binop_name("value_pos_vfloat"), partialmethod(_TestNumericField._test_binop_value_pos_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_neg_vfloat'), + test_binop_name("value_neg_vfloat"), partialmethod(_TestNumericField._test_binop_value_neg_vfloat, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_float'), + test_binop_name("lhs_addr_same_pos_float"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_pos_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_float'), + test_binop_name("lhs_addr_same_neg_float"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_neg_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_vfloat'), + test_binop_name("lhs_addr_same_pos_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_pos_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_vfloat'), + test_binop_name("lhs_addr_same_neg_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_neg_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_float'), + test_binop_name("lhs_value_same_pos_float"), partialmethod( _TestNumericField._test_binop_lhs_value_same_pos_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_float'), + test_binop_name("lhs_value_same_neg_float"), partialmethod( _TestNumericField._test_binop_lhs_value_same_neg_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_vfloat'), + test_binop_name("lhs_value_same_pos_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_value_same_pos_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_vfloat'), + test_binop_name("lhs_value_same_neg_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_value_same_neg_vfloat, op=binop ), ) setattr( cls, - test_binop_name('type_zero_float'), + test_binop_name("type_zero_float"), partialmethod(_TestNumericField._test_binop_type_zero_float, op=binop), ) setattr( cls, - test_binop_name('type_zero_vfloat'), + test_binop_name("type_zero_vfloat"), partialmethod(_TestNumericField._test_binop_type_zero_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_zero_float'), + test_binop_name("value_zero_float"), partialmethod(_TestNumericField._test_binop_value_zero_float, op=binop), ) setattr( cls, - test_binop_name('value_zero_vfloat'), + test_binop_name("value_zero_vfloat"), partialmethod(_TestNumericField._test_binop_value_zero_vfloat, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_float'), + test_binop_name("lhs_addr_same_zero_float"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_zero_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_vfloat'), + test_binop_name("lhs_addr_same_zero_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_zero_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_float'), + test_binop_name("lhs_value_same_zero_float"), partialmethod( _TestNumericField._test_binop_lhs_value_same_zero_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_vfloat'), + test_binop_name("lhs_value_same_zero_vfloat"), partialmethod( _TestNumericField._test_binop_lhs_value_same_zero_vfloat, op=binop ), ) setattr( cls, - test_binop_name('type_complex'), + test_binop_name("type_complex"), partialmethod(_TestNumericField._test_binop_type_complex, op=binop), ) setattr( cls, - test_binop_name('type_zero_complex'), + test_binop_name("type_zero_complex"), partialmethod(_TestNumericField._test_binop_type_zero_complex, op=binop), ) setattr( cls, - test_binop_name('value_complex'), + test_binop_name("value_complex"), partialmethod(_TestNumericField._test_binop_value_complex, op=binop), ) setattr( cls, - test_binop_name('value_zero_complex'), + test_binop_name("value_zero_complex"), partialmethod(_TestNumericField._test_binop_value_zero_complex, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_complex'), + test_binop_name("lhs_addr_same_complex"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_complex'), + test_binop_name("lhs_addr_same_zero_complex"), partialmethod( _TestNumericField._test_binop_lhs_addr_same_zero_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_complex'), + test_binop_name("lhs_value_same_complex"), partialmethod( _TestNumericField._test_binop_lhs_value_same_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_complex'), + test_binop_name("lhs_value_same_zero_complex"), partialmethod( _TestNumericField._test_binop_lhs_value_same_zero_complex, op=binop ), @@ -1110,22 +1110,22 @@ def _inject_numeric_testing_methods(cls): for name, unaryop in _UNARYOPS: setattr( cls, - test_unaryop_name('type'), + test_unaryop_name("type"), partialmethod(_TestNumericField._test_unaryop_type, op=unaryop), ) setattr( cls, - test_unaryop_name('value'), + test_unaryop_name("value"), partialmethod(_TestNumericField._test_unaryop_value, op=unaryop), ) setattr( cls, - test_unaryop_name('addr_same'), + test_unaryop_name("addr_same"), partialmethod(_TestNumericField._test_unaryop_addr_same, op=unaryop), ) setattr( cls, - test_unaryop_name('value_same'), + test_unaryop_name("value_same"), partialmethod(_TestNumericField._test_unaryop_value_same, op=unaryop), ) @@ -1217,7 +1217,7 @@ class _TestIntegerFieldCommon(_TestNumericField): def test_assign_invalid_type(self): with self.assertRaises(TypeError): - self._def.value = 'yes' + self._def.value = "yes" def test_assign_uint(self): uint_fc = self._tc.create_unsigned_integer_field_class(32) @@ -1242,12 +1242,12 @@ class _TestIntegerFieldCommon(_TestNumericField): with self.assertRaises(ValueError) as ctx: field.value = 256 self.assertEqual( - str(ctx.exception), 'Value 256 is outside valid range [0, 255]' + str(ctx.exception), "Value 256 is outside valid range [0, 255]" ) with self.assertRaises(ValueError) as ctx: field.value = -1 - self.assertEqual(str(ctx.exception), 'Value -1 is outside valid range [0, 255]') + self.assertEqual(str(ctx.exception), "Value -1 is outside valid range [0, 255]") def test_assign_int_out_of_range(self): int_fc = self._tc.create_signed_integer_field_class(8) @@ -1256,13 +1256,13 @@ class _TestIntegerFieldCommon(_TestNumericField): with self.assertRaises(ValueError) as ctx: field.value = 128 self.assertEqual( - str(ctx.exception), 'Value 128 is outside valid range [-128, 127]' + str(ctx.exception), "Value 128 is outside valid range [-128, 127]" ) with self.assertRaises(ValueError) as ctx: field.value = -129 self.assertEqual( - str(ctx.exception), 'Value -129 is outside valid range [-128, 127]' + str(ctx.exception), "Value -129 is outside valid range [-128, 127]" ) def test_str_op(self): @@ -1300,13 +1300,13 @@ class SignedEnumerationFieldTestCase(_TestIntegerFieldCommon, unittest.TestCase) def _create_fc(self, tc): fc = tc.create_signed_enumeration_field_class(32) - fc.add_mapping('something', bt2.SignedIntegerRangeSet([(17, 17)])) - fc.add_mapping('speaker', bt2.SignedIntegerRangeSet([(12, 16)])) - fc.add_mapping('can', bt2.SignedIntegerRangeSet([(18, 2540)])) + fc.add_mapping("something", bt2.SignedIntegerRangeSet([(17, 17)])) + fc.add_mapping("speaker", bt2.SignedIntegerRangeSet([(12, 16)])) + fc.add_mapping("can", bt2.SignedIntegerRangeSet([(18, 2540)])) fc.add_mapping( - 'whole range', bt2.SignedIntegerRangeSet([(-(2**31), (2**31) - 1)]) + "whole range", bt2.SignedIntegerRangeSet([(-(2**31), (2**31) - 1)]) ) - fc.add_mapping('zip', bt2.SignedIntegerRangeSet([(-45, 1001)])) + fc.add_mapping("zip", bt2.SignedIntegerRangeSet([(-45, 1001)])) return fc def setUp(self): @@ -1327,8 +1327,8 @@ class SignedEnumerationFieldTestCase(_TestIntegerFieldCommon, unittest.TestCase) # Establish all permutations of the three expected matches since # the order in which mappings are enumerated is not explicitly part of # the API. - for p in itertools.permutations(['whole range', 'something', 'zip']): - candidate = '{} ({})'.format(self._def_value, ', '.join(p)) + for p in itertools.permutations(["whole range", "something", "zip"]): + candidate = "{} ({})".format(self._def_value, ", ".join(p)) if candidate == s: expected_string_found = True break @@ -1338,7 +1338,7 @@ class SignedEnumerationFieldTestCase(_TestIntegerFieldCommon, unittest.TestCase) def test_labels(self): self._field.value = 17 labels = sorted(self._field.labels) - self.assertEqual(labels, ['something', 'whole range', 'zip']) + self.assertEqual(labels, ["something", "whole range", "zip"]) class SingleRealFieldTestCase(_TestNumericField, unittest.TestCase): @@ -1410,7 +1410,7 @@ class SingleRealFieldTestCase(_TestNumericField, unittest.TestCase): def test_assign_invalid_type(self): with self.assertRaises(TypeError): - self._def.value = 'yes' + self._def.value = "yes" def test_invalid_lshift(self): self._test_invalid_op(lambda: self._def << 23) @@ -1502,7 +1502,7 @@ class DoubleRealFieldTestCase(_TestNumericField, unittest.TestCase): def test_assign_invalid_type(self): with self.assertRaises(TypeError): - self._def.value = 'yes' + self._def.value = "yes" def test_invalid_lshift(self): self._test_invalid_op(lambda: self._def << 23) @@ -1532,17 +1532,17 @@ _inject_numeric_testing_methods(DoubleRealFieldTestCase) class StringFieldTestCase(unittest.TestCase): @staticmethod def _const_value_setter(field): - field.value = 'Hello, World!' + field.value = "Hello, World!" def setUp(self): self._tc = get_default_trace_class() - self._def_value = 'Hello, World!' + self._def_value = "Hello, World!" self._def = _create_string_field(self._tc) self._def_const = create_const_field( self._tc, self._tc.create_string_field_class(), self._const_value_setter ) self._def.value = self._def_value - self._def_new_value = 'Yes!' + self._def_new_value = "Yes!" def test_assign_int(self): with self.assertRaises(TypeError): @@ -1550,7 +1550,7 @@ class StringFieldTestCase(unittest.TestCase): def test_assign_string_field(self): field = _create_string_field(self._tc) - raw = 'zorg' + raw = "zorg" field.value = raw self.assertEqual(field, raw) @@ -1565,51 +1565,51 @@ class StringFieldTestCase(unittest.TestCase): def test_lt_vstring(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' + s1.value = "allo" s2 = _create_string_field(self._tc) - s2.value = 'bateau' + s2.value = "bateau" self.assertLess(s1, s2) def test_lt_string(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' - self.assertLess(s1, 'bateau') + s1.value = "allo" + self.assertLess(s1, "bateau") def test_le_vstring(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' + s1.value = "allo" s2 = _create_string_field(self._tc) - s2.value = 'bateau' + s2.value = "bateau" self.assertLessEqual(s1, s2) def test_le_string(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' - self.assertLessEqual(s1, 'bateau') + s1.value = "allo" + self.assertLessEqual(s1, "bateau") def test_gt_vstring(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' + s1.value = "allo" s2 = _create_string_field(self._tc) - s2.value = 'bateau' + s2.value = "bateau" self.assertGreater(s2, s1) def test_gt_string(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' - self.assertGreater('bateau', s1) + s1.value = "allo" + self.assertGreater("bateau", s1) def test_ge_vstring(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' + s1.value = "allo" s2 = _create_string_field(self._tc) - s2.value = 'bateau' + s2.value = "bateau" self.assertGreaterEqual(s2, s1) def test_ge_string(self): s1 = _create_string_field(self._tc) - s1.value = 'allo' - self.assertGreaterEqual('bateau', s1) + s1.value = "allo" + self.assertGreaterEqual("bateau", s1) def test_bool_op(self): self.assertEqual(bool(self._def), bool(self._def_value)) @@ -1627,20 +1627,20 @@ class StringFieldTestCase(unittest.TestCase): self.assertEqual(self._def_const[5], self._def_value[5]) def test_append_str(self): - to_append = 'meow meow meow' + to_append = "meow meow meow" self._def += to_append self._def_value += to_append self.assertEqual(self._def, self._def_value) def test_const_append_str(self): - to_append = 'meow meow meow' + to_append = "meow meow meow" with self.assertRaises(TypeError): self._def_const += to_append self.assertEqual(self._def_const, self._def_value) def test_append_string_field(self): field = _create_string_field(self._tc) - to_append = 'meow meow meow' + to_append = "meow meow meow" field.value = to_append self._def += field self._def_value += to_append @@ -1655,8 +1655,8 @@ class StringFieldTestCase(unittest.TestCase): def test_const_hash_dict(self): my_dict = {} - my_dict[self._def_const] = 'my_value' - self.assertEqual(my_dict[self._def_value], 'my_value') + my_dict[self._def_const] = "my_value" + self.assertEqual(my_dict[self._def_value], "my_value") class _TestArrayFieldCommon: @@ -1736,7 +1736,7 @@ class _TestArrayFieldCommon: def test_setitem_index_wrong_type(self): with self.assertRaises(TypeError): - self._def['yes'] = 23 + self._def["yes"] = 23 def test_setitem_index_neg(self): with self.assertRaises(IndexError): @@ -1769,7 +1769,7 @@ class _TestArrayFieldCommon: self._def.value = values def test_value_wrong_type_in_sequence(self): - values = [32, 'hello', 11] + values = [32, "hello", 11] with self.assertRaises(TypeError): self._def.value = values @@ -1778,27 +1778,27 @@ class _TestArrayFieldCommon: int_fc = self._tc.create_signed_integer_field_class(32) another_int_fc = self._tc.create_signed_integer_field_class(32) str_fc = self._tc.create_string_field_class() - struct_fc.append_member(field_class=int_fc, name='an_int') - struct_fc.append_member(field_class=str_fc, name='a_string') - struct_fc.append_member(field_class=another_int_fc, name='another_int') + struct_fc.append_member(field_class=int_fc, name="an_int") + struct_fc.append_member(field_class=str_fc, name="a_string") + struct_fc.append_member(field_class=another_int_fc, name="another_int") array_fc = self._tc.create_static_array_field_class(struct_fc, 3) - stream = _create_stream(self._tc, [('array_field', array_fc)]) + stream = _create_stream(self._tc, [("array_field", array_fc)]) values = [ - {'an_int': 42, 'a_string': 'hello', 'another_int': 66}, - {'an_int': 1, 'a_string': 'goodbye', 'another_int': 488}, - {'an_int': 156, 'a_string': 'or not', 'another_int': 4648}, + {"an_int": 42, "a_string": "hello", "another_int": 66}, + {"an_int": 1, "a_string": "goodbye", "another_int": 488}, + {"an_int": 156, "a_string": "or not", "another_int": 4648}, ] - array = stream.create_packet().context_field['array_field'] + array = stream.create_packet().context_field["array_field"] array.value = values self.assertEqual(values, array) - values[0]['an_int'] = 'a string' + values[0]["an_int"] = "a string" with self.assertRaises(TypeError): array.value = values def test_str_op(self): s = str(self._def) - expected_string = '[{}]'.format(', '.join([repr(v) for v in self._def_value])) + expected_string = "[{}]".format(", ".join([repr(v) for v in self._def_value])) self.assertEqual(expected_string, s) @@ -1865,31 +1865,31 @@ class DynamicArrayFieldTestCase(_TestArrayFieldCommon, unittest.TestCase): def test_set_invalid_length(self): with self.assertRaises(TypeError): - self._def.length = 'cheval' + self._def.length = "cheval" class StructureFieldTestCase(unittest.TestCase): @staticmethod def _const_value_setter(field): field.value = { - 'A': -1872, - 'B': 'salut', - 'C': 17.5, - 'D': 16497, - 'E': {}, - 'F': {'F_1': 52}, + "A": -1872, + "B": "salut", + "C": 17.5, + "D": 16497, + "E": {}, + "F": {"F_1": 52}, } def _create_fc(self, tc): fc = tc.create_structure_field_class() - fc.append_member('A', self._fc0_fn()) - fc.append_member('B', self._fc1_fn()) - fc.append_member('C', self._fc2_fn()) - fc.append_member('D', self._fc3_fn()) - fc.append_member('E', self._fc4_fn()) + fc.append_member("A", self._fc0_fn()) + fc.append_member("B", self._fc1_fn()) + fc.append_member("C", self._fc2_fn()) + fc.append_member("D", self._fc3_fn()) + fc.append_member("E", self._fc4_fn()) fc5 = self._fc5_fn() - fc5.append_member('F_1', self._fc5_inner_fn()) - fc.append_member('F', fc5) + fc5.append_member("F_1", self._fc5_inner_fn()) + fc.append_member("F", fc5) return fc def setUp(self): @@ -1904,19 +1904,19 @@ class StructureFieldTestCase(unittest.TestCase): self._fc = self._create_fc(self._tc) self._def = _create_field(self._tc, self._fc) - self._def['A'] = -1872 - self._def['B'] = 'salut' - self._def['C'] = 17.5 - self._def['D'] = 16497 - self._def['E'] = {} - self._def['F'] = {'F_1': 52} + self._def["A"] = -1872 + self._def["B"] = "salut" + self._def["C"] = 17.5 + self._def["D"] = 16497 + self._def["E"] = {} + self._def["F"] = {"F_1": 52} self._def_value = { - 'A': -1872, - 'B': 'salut', - 'C': 17.5, - 'D': 16497, - 'E': {}, - 'F': {'F_1': 52}, + "A": -1872, + "B": "salut", + "C": 17.5, + "D": 16497, + "E": {}, + "F": {"F_1": 52}, } self._def_const = create_const_field( @@ -1924,31 +1924,31 @@ class StructureFieldTestCase(unittest.TestCase): ) def _modify_def(self): - self._def['B'] = 'hola' + self._def["B"] = "hola" def test_bool_op_true(self): self.assertTrue(self._def) def test_bool_op_false(self): - field = self._def['E'] + field = self._def["E"] self.assertFalse(field) def test_len(self): self.assertEqual(len(self._def), len(self._def_value)) def test_getitem(self): - field1 = self._def['A'] - field2 = self._def['B'] - field3 = self._def['C'] - field4 = self._def['D'] - field5 = self._def['E'] - field6 = self._def['F'] + field1 = self._def["A"] + field2 = self._def["B"] + field3 = self._def["C"] + field4 = self._def["D"] + field5 = self._def["E"] + field6 = self._def["F"] self.assertIs(type(field1), bt2._SignedIntegerField) self.assertEqual(field1, -1872) self.assertIs(type(field2), bt2._StringField) - self.assertEqual(field2, 'salut') + self.assertEqual(field2, "salut") self.assertIs(type(field3), bt2._DoublePrecisionRealField) self.assertEqual(field3, 17.5) @@ -1960,21 +1960,21 @@ class StructureFieldTestCase(unittest.TestCase): self.assertEqual(field5, {}) self.assertIs(type(field6), bt2._StructureField) - self.assertEqual(field6, {'F_1': 52}) + self.assertEqual(field6, {"F_1": 52}) def test_const_getitem(self): - field1 = self._def_const['A'] - field2 = self._def_const['B'] - field3 = self._def_const['C'] - field4 = self._def_const['D'] - field5 = self._def_const['E'] - field6 = self._def_const['F'] + field1 = self._def_const["A"] + field2 = self._def_const["B"] + field3 = self._def_const["C"] + field4 = self._def_const["D"] + field5 = self._def_const["E"] + field6 = self._def_const["F"] self.assertIs(type(field1), bt2._SignedIntegerFieldConst) self.assertEqual(field1, -1872) self.assertIs(type(field2), bt2._StringFieldConst) - self.assertEqual(field2, 'salut') + self.assertEqual(field2, "salut") self.assertIs(type(field3), bt2._DoublePrecisionRealFieldConst) self.assertEqual(field3, 17.5) @@ -1986,7 +1986,7 @@ class StructureFieldTestCase(unittest.TestCase): self.assertEqual(field5, {}) self.assertIs(type(field6), bt2._StructureFieldConst) - self.assertEqual(field6, {'F_1': 52}) + self.assertEqual(field6, {"F_1": 52}) def test_member_at_index_out_of_bounds_after(self): with self.assertRaises(IndexError): @@ -1994,22 +1994,22 @@ class StructureFieldTestCase(unittest.TestCase): def test_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field['A'] = -1872 - field['B'] = 'salut' - field['C'] = 17.5 - field['D'] = 16497 - field['E'] = {} - field['F'] = {'F_1': 52} + field["A"] = -1872 + field["B"] = "salut" + field["C"] = 17.5 + field["D"] = 16497 + field["E"] = {} + field["F"] = {"F_1": 52} self.assertEqual(self._def, field) def test_const_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field['A'] = -1872 - field['B'] = 'salut' - field['C'] = 17.5 - field['D'] = 16497 - field['E'] = {} - field['F'] = {'F_1': 52} + field["A"] = -1872 + field["B"] = "salut" + field["C"] = 17.5 + field["D"] = 16497 + field["E"] = {} + field["F"] = {"F_1": 52} self.assertEqual(self._def_const, field) def test_eq_invalid_type(self): @@ -2017,88 +2017,88 @@ class StructureFieldTestCase(unittest.TestCase): def test_eq_diff_len(self): fc = self._tc.create_structure_field_class() - fc.append_member('A', self._fc0_fn()) - fc.append_member('B', self._fc1_fn()) - fc.append_member('C', self._fc2_fn()) + fc.append_member("A", self._fc0_fn()) + fc.append_member("B", self._fc1_fn()) + fc.append_member("C", self._fc2_fn()) field = _create_field(self._tc, fc) - field['A'] = -1872 - field['B'] = 'salut' - field['C'] = 17.5 + field["A"] = -1872 + field["B"] = "salut" + field["C"] = 17.5 self.assertNotEqual(self._def, field) def test_eq_diff_keys(self): fc = self._tc.create_structure_field_class() - fc.append_member('U', self._fc0_fn()) - fc.append_member('V', self._fc1_fn()) - fc.append_member('W', self._fc2_fn()) - fc.append_member('X', self._fc3_fn()) - fc.append_member('Y', self._fc4_fn()) - fc.append_member('Z', self._fc5_fn()) + fc.append_member("U", self._fc0_fn()) + fc.append_member("V", self._fc1_fn()) + fc.append_member("W", self._fc2_fn()) + fc.append_member("X", self._fc3_fn()) + fc.append_member("Y", self._fc4_fn()) + fc.append_member("Z", self._fc5_fn()) field = _create_field(self._tc, fc) - field['U'] = -1871 - field['V'] = "gerry" - field['W'] = 18.19 - field['X'] = 16497 - field['Y'] = {} - field['Z'] = {} + field["U"] = -1871 + field["V"] = "gerry" + field["W"] = 18.19 + field["X"] = 16497 + field["Y"] = {} + field["Z"] = {} self.assertNotEqual(self._def, field) def test_eq_diff_content_same_len(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field['A'] = -1872 - field['B'] = 'salut' - field['C'] = 17.4 - field['D'] = 16497 - field['E'] = {} - field['F'] = {'F_1': 0} + field["A"] = -1872 + field["B"] = "salut" + field["C"] = 17.4 + field["D"] = 16497 + field["E"] = {} + field["F"] = {"F_1": 0} self.assertNotEqual(self._def, field) def test_eq_same_content_diff_keys(self): fc = self._tc.create_structure_field_class() - fc.append_member('A', self._fc0_fn()) - fc.append_member('B', self._fc1_fn()) - fc.append_member('E', self._fc2_fn()) - fc.append_member('D', self._fc3_fn()) - fc.append_member('C', self._fc4_fn()) - fc.append_member('F', self._fc5_fn()) + fc.append_member("A", self._fc0_fn()) + fc.append_member("B", self._fc1_fn()) + fc.append_member("E", self._fc2_fn()) + fc.append_member("D", self._fc3_fn()) + fc.append_member("C", self._fc4_fn()) + fc.append_member("F", self._fc5_fn()) field = _create_field(self._tc, fc) - field['A'] = -1872 - field['B'] = 'salut' - field['E'] = 17.5 - field['D'] = 16497 - field['C'] = {} - field['F'] = {} + field["A"] = -1872 + field["B"] = "salut" + field["E"] = 17.5 + field["D"] = 16497 + field["C"] = {} + field["F"] = {} self.assertNotEqual(self._def, field) def test_setitem(self): - self._def['C'] = -18.47 - self.assertEqual(self._def['C'], -18.47) + self._def["C"] = -18.47 + self.assertEqual(self._def["C"], -18.47) def test_const_setitem(self): with self.assertRaises(TypeError): - self._def_const['A'] = 134679 + self._def_const["A"] = 134679 def test_setitem_int_field(self): int_fc = self._tc.create_signed_integer_field_class(32) int_field = _create_field(self._tc, int_fc) int_field.value = 19487 - self._def['D'] = int_field - self.assertEqual(self._def['D'], 19487) + self._def["D"] = int_field + self.assertEqual(self._def["D"], 19487) def test_setitem_non_basic_field(self): elem_fc = self._tc.create_structure_field_class() struct_fc = self._tc.create_structure_field_class() - struct_fc.append_member('A', elem_fc) + struct_fc.append_member("A", elem_fc) struct_field = _create_field(self._tc, struct_fc) # Will fail on access to .items() of the value with self.assertRaises(AttributeError): - struct_field['A'] = 23 + struct_field["A"] = 23 def test_setitem_none(self): with self.assertRaises(TypeError): - self._def['C'] = None + self._def["C"] = None def test_setitem_key_wrong_type(self): with self.assertRaises(TypeError): @@ -2106,22 +2106,22 @@ class StructureFieldTestCase(unittest.TestCase): def test_setitem_wrong_key(self): with self.assertRaises(KeyError): - self._def['hi'] = 134679 + self._def["hi"] = 134679 def test_member_at_index(self): - self.assertEqual(self._def.member_at_index(1), 'salut') + self.assertEqual(self._def.member_at_index(1), "salut") def test_const_member_at_index(self): - self.assertEqual(self._def_const.member_at_index(1), 'salut') + self.assertEqual(self._def_const.member_at_index(1), "salut") def test_iter(self): orig_values = { - 'A': -1872, - 'B': 'salut', - 'C': 17.5, - 'D': 16497, - 'E': {}, - 'F': {'F_1': 52}, + "A": -1872, + "B": "salut", + "C": 17.5, + "D": 16497, + "E": {}, + "F": {"F_1": 52}, } for vkey, vval in self._def.items(): @@ -2130,12 +2130,12 @@ class StructureFieldTestCase(unittest.TestCase): def test_value(self): orig_values = { - 'A': -1872, - 'B': 'salut', - 'C': 17.5, - 'D': 16497, - 'E': {}, - 'F': {'F_1': 52}, + "A": -1872, + "B": "salut", + "C": 17.5, + "D": 16497, + "E": {}, + "F": {"F_1": 52}, } self.assertEqual(self._def, orig_values) @@ -2144,22 +2144,22 @@ class StructureFieldTestCase(unittest.TestCase): another_int_fc = self._tc.create_signed_integer_field_class(32) str_fc = self._tc.create_string_field_class() struct_fc = self._tc.create_structure_field_class() - struct_fc.append_member(field_class=int_fc, name='an_int') - struct_fc.append_member(field_class=str_fc, name='a_string') - struct_fc.append_member(field_class=another_int_fc, name='another_int') - values = {'an_int': 42, 'a_string': 'hello', 'another_int': 66} + struct_fc.append_member(field_class=int_fc, name="an_int") + struct_fc.append_member(field_class=str_fc, name="a_string") + struct_fc.append_member(field_class=another_int_fc, name="another_int") + values = {"an_int": 42, "a_string": "hello", "another_int": 66} struct = _create_field(self._tc, struct_fc) struct.value = values self.assertEqual(values, struct) bad_type_values = copy.deepcopy(values) - bad_type_values['an_int'] = 'a string' + bad_type_values["an_int"] = "a string" with self.assertRaises(TypeError): struct.value = bad_type_values unknown_key_values = copy.deepcopy(values) - unknown_key_values['unknown_key'] = 16546 + unknown_key_values["unknown_key"] = 16546 with self.assertRaises(KeyError): struct.value = unknown_key_values @@ -2170,8 +2170,8 @@ class StructureFieldTestCase(unittest.TestCase): # the order in which mappings are enumerated is not explicitly part of # the API. for p in itertools.permutations([(k, v) for k, v in self._def.items()]): - items = ['{}: {}'.format(repr(k), repr(v)) for k, v in p] - candidate = '{{{}}}'.format(', '.join(items)) + items = ["{}: {}".format(repr(k), repr(v)) for k, v in p] + candidate = "{{{}}}".format(", ".join(items)) if candidate == s: expected_string_found = True break @@ -2182,34 +2182,34 @@ class StructureFieldTestCase(unittest.TestCase): class OptionFieldTestCase(unittest.TestCase): @staticmethod def _const_value_setter(field): - field.value = {'opt_field': 'hiboux'} + field.value = {"opt_field": "hiboux"} def _create_fc(self, tc): fc = tc.create_option_without_selector_field_class( tc.create_string_field_class() ) top_fc = tc.create_structure_field_class() - top_fc.append_member('opt_field', fc) + top_fc.append_member("opt_field", fc) return top_fc def setUp(self): self._tc = get_default_trace_class() fld = _create_field(self._tc, self._create_fc(self._tc)) - self._def = fld['opt_field'] - self._def_value = 'hiboux' + self._def = fld["opt_field"] + self._def_value = "hiboux" self._def_const = create_const_field( self._tc, self._create_fc(self._tc), self._const_value_setter - )['opt_field'] + )["opt_field"] def test_value_prop(self): - self._def.value = 'hiboux' - self.assertEqual(self._def.field, 'hiboux') + self._def.value = "hiboux" + self.assertEqual(self._def.field, "hiboux") self.assertIs(type(self._def), bt2._OptionField) self.assertIs(type(self._def.field), bt2._StringField) self.assertTrue(self._def.has_field) def test_const_value_prop(self): - self.assertEqual(self._def_const.field, 'hiboux') + self.assertEqual(self._def_const.field, "hiboux") self.assertIs(type(self._def_const), bt2._OptionFieldConst) self.assertIs(type(self._def_const.field), bt2._StringFieldConst) self.assertTrue(self._def_const.has_field) @@ -2223,7 +2223,7 @@ class OptionFieldTestCase(unittest.TestCase): self.assertFalse(self._def.has_field) def test_bool_op_true(self): - self._def.value = 'allo' + self._def.value = "allo" self.assertTrue(self._def) def test_bool_op_false(self): @@ -2231,9 +2231,9 @@ class OptionFieldTestCase(unittest.TestCase): self.assertFalse(self._def) def test_field_prop_existing(self): - self._def.value = 'meow' + self._def.value = "meow" field = self._def.field - self.assertEqual(field, 'meow') + self.assertEqual(field, "meow") def test_field_prop_none(self): self._def.has_field = False @@ -2248,37 +2248,37 @@ class OptionFieldTestCase(unittest.TestCase): self.assertTrue(self._def_const.has_field) def test_field_prop_existing_then_none(self): - self._def.value = 'meow' + self._def.value = "meow" field = self._def.field - self.assertEqual(field, 'meow') + self.assertEqual(field, "meow") self._def.has_field = False field = self._def.field self.assertIsNone(field) def test_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['opt_field'] - field.value = 'walk' - self._def.value = 'walk' + field = field["opt_field"] + field.value = "walk" + self._def.value = "walk" self.assertEqual(self._def, field) def test_const_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['opt_field'] - field.value = 'hiboux' + field = field["opt_field"] + field.value = "hiboux" self.assertEqual(self._def_const, field) self.assertEqual(self._def_const, self._def_value) def test_eq_invalid_type(self): - self._def.value = 'gerry' + self._def.value = "gerry" self.assertNotEqual(self._def, 23) def test_str_op(self): - self._def.value = 'marcel' + self._def.value = "marcel" self.assertEqual(str(self._def), str(self._def.field)) def test_repr_op(self): - self._def.value = 'mireille' + self._def.value = "mireille" self.assertEqual(repr(self._def), repr(self._def.field)) @@ -2294,22 +2294,22 @@ class VariantFieldTestCase(unittest.TestCase): ft2 = tc.create_double_precision_real_field_class() ft3 = tc.create_signed_integer_field_class(17) fc = tc.create_variant_field_class() - fc.append_option('corner', ft0) - fc.append_option('zoom', ft1) - fc.append_option('mellotron', ft2) - fc.append_option('giorgio', ft3) + fc.append_option("corner", ft0) + fc.append_option("zoom", ft1) + fc.append_option("mellotron", ft2) + fc.append_option("giorgio", ft3) top_fc = tc.create_structure_field_class() - top_fc.append_member('variant_field', fc) + top_fc.append_member("variant_field", fc) return top_fc def setUp(self): self._tc = get_default_trace_class() fld = _create_field(self._tc, self._create_fc(self._tc)) - self._def = fld['variant_field'] + self._def = fld["variant_field"] self._def_value = 1334 self._def_selected_index = 3 - const_fc = self._create_fc(self._tc)['variant_field'] + const_fc = self._create_fc(self._tc)["variant_field"] fld_const = create_const_field( self._tc, const_fc.field_class, self._const_value_setter @@ -2358,7 +2358,7 @@ class VariantFieldTestCase(unittest.TestCase): def test_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['variant_field'] + field = field["variant_field"] field.selected_option_index = 0 field.value = 1774 self._def.selected_option_index = 0 @@ -2367,7 +2367,7 @@ class VariantFieldTestCase(unittest.TestCase): def test_const_eq(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['variant_field'] + field = field["variant_field"] field.selected_option_index = 3 field.value = 1334 self.assertEqual(self._def_const, field) @@ -2377,42 +2377,42 @@ class VariantFieldTestCase(unittest.TestCase): def test_eq_invalid_type(self): self._def.selected_option_index = 1 - self._def.value = 'gerry' + self._def.value = "gerry" self.assertNotEqual(self._def, 23) def test_str_op_int(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['variant_field'] + field = field["variant_field"] field.selected_option_index = 0 field.value = 1774 other_field = _create_field(self._tc, self._create_fc(self._tc)) - other_field = other_field['variant_field'] + other_field = other_field["variant_field"] other_field.selected_option_index = 0 other_field.value = 1774 self.assertEqual(str(field), str(other_field)) def test_str_op_str(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['variant_field'] + field = field["variant_field"] field.selected_option_index = 1 - field.value = 'un beau grand bateau' + field.value = "un beau grand bateau" other_field = _create_field(self._tc, self._create_fc(self._tc)) - other_field = other_field['variant_field'] + other_field = other_field["variant_field"] other_field.selected_option_index = 1 - other_field.value = 'un beau grand bateau' + other_field.value = "un beau grand bateau" self.assertEqual(str(field), str(other_field)) def test_str_op_float(self): field = _create_field(self._tc, self._create_fc(self._tc)) - field = field['variant_field'] + field = field["variant_field"] field.selected_option_index = 2 field.value = 14.4245 other_field = _create_field(self._tc, self._create_fc(self._tc)) - other_field = other_field['variant_field'] + other_field = other_field["variant_field"] other_field.selected_option_index = 2 other_field.value = 14.4245 self.assertEqual(str(field), str(other_field)) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_field_class.py b/tests/bindings/python/bt2/test_field_class.py index cc6a54bc..d12e3987 100644 --- a/tests/bindings/python/bt2/test_field_class.py +++ b/tests/bindings/python/bt2/test_field_class.py @@ -25,7 +25,7 @@ def _create_stream(tc, ctx_field_classes): def _create_const_field_class(tc, field_class, value_setter_fn): - field_name = 'const field' + field_name = "const field" class MyIter(bt2._UserMessageIterator): def __init__(self, config, self_port_output): @@ -49,11 +49,11 @@ def _create_const_field_class(tc, field_class, value_setter_fn): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out', params) + self._add_output_port("out", params) graph = bt2.Graph() - src_comp = graph.add_component(MySrc, 'my_source', None) - msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports['out']) + src_comp = graph.add_component(MySrc, "my_source", None) + msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports["out"]) # Ignore first message, stream beginning _ = next(msg_iter) @@ -64,13 +64,13 @@ def _create_const_field_class(tc, field_class, value_setter_fn): class _TestFieldClass: def test_create_user_attributes(self): - fc = self._create_default_field_class(user_attributes={'salut': 23}) - self.assertEqual(fc.user_attributes, {'salut': 23}) + fc = self._create_default_field_class(user_attributes={"salut": 23}) + self.assertEqual(fc.user_attributes, {"salut": 23}) self.assertIs(type(fc.user_attributes), bt2_value.MapValue) def test_const_create_user_attributes(self): - fc = self._create_default_const_field_class(user_attributes={'salut': 23}) - self.assertEqual(fc.user_attributes, {'salut': 23}) + fc = self._create_default_const_field_class(user_attributes={"salut": 23}) + self.assertEqual(fc.user_attributes, {"salut": 23}) self.assertIs(type(fc.user_attributes), bt2_value._MapValueConst) def test_create_invalid_user_attributes(self): @@ -139,7 +139,7 @@ class BitArrayFieldClassTestCase(_TestFieldClass, unittest.TestCase): def test_create_length_invalid_type(self): with self.assertRaises(TypeError): - self._create_field_class('lel') + self._create_field_class("lel") def test_length_prop(self): self.assertEqual(self._fc.length, 17) @@ -161,10 +161,10 @@ class _TestIntegerFieldClassProps: def test_create_invalid_range(self): with self.assertRaises(TypeError): - self._create_field_class('yes') + self._create_field_class("yes") with self.assertRaises(TypeError): - self._create_field_class(field_value_range='yes') + self._create_field_class(field_value_range="yes") with self.assertRaises(ValueError): self._create_field_class(field_value_range=-2) @@ -180,7 +180,7 @@ class _TestIntegerFieldClassProps: def test_create_invalid_base_type(self): with self.assertRaises(TypeError): - self._create_field_class(preferred_display_base='yes') + self._create_field_class(preferred_display_base="yes") def test_create_invalid_base_value(self): with self.assertRaises(ValueError): @@ -291,22 +291,22 @@ class _EnumerationFieldClassTestCase(_TestIntegerFieldClassProps): def test_create_from_invalid_type(self): with self.assertRaises(TypeError): - self._create_field_class('coucou') + self._create_field_class("coucou") def test_add_mapping_simple(self): - self._fc.add_mapping('hello', self._ranges1) - mapping = self._fc['hello'] - self.assertEqual(mapping.label, 'hello') + self._fc.add_mapping("hello", self._ranges1) + mapping = self._fc["hello"] + self.assertEqual(mapping.label, "hello") self.assertEqual(mapping.ranges, self._ranges1) def test_const_add_mapping(self): with self.assertRaises(AttributeError): - self._fc_const.add_mapping('hello', self._ranges1) + self._fc_const.add_mapping("hello", self._ranges1) def test_add_mapping_simple_kwargs(self): - self._fc.add_mapping(label='hello', ranges=self._ranges1) - mapping = self._fc['hello'] - self.assertEqual(mapping.label, 'hello') + self._fc.add_mapping(label="hello", ranges=self._ranges1) + mapping = self._fc["hello"] + self.assertEqual(mapping.label, "hello") self.assertEqual(mapping.ranges, self._ranges1) def test_add_mapping_invalid_name(self): @@ -315,76 +315,76 @@ class _EnumerationFieldClassTestCase(_TestIntegerFieldClassProps): def test_add_mapping_invalid_range(self): with self.assertRaises(TypeError): - self._fc.add_mapping('allo', 'meow') + self._fc.add_mapping("allo", "meow") def test_add_mapping_dup_label(self): with self.assertRaises(ValueError): - self._fc.add_mapping('a', self._ranges1) - self._fc.add_mapping('a', self._ranges2) + self._fc.add_mapping("a", self._ranges1) + self._fc.add_mapping("a", self._ranges2) def test_add_mapping_invalid_ranges_signedness(self): with self.assertRaises(TypeError): - self._fc.add_mapping('allo', self._inval_ranges) + self._fc.add_mapping("allo", self._inval_ranges) def test_iadd(self): - self._fc.add_mapping('c', self._ranges1) + self._fc.add_mapping("c", self._ranges1) - self._fc += [('d', self._ranges2), ('e', self._ranges3)] + self._fc += [("d", self._ranges2), ("e", self._ranges3)] self.assertEqual(len(self._fc), 3) - self.assertEqual(self._fc['c'].label, 'c') - self.assertEqual(self._fc['c'].ranges, self._ranges1) - self.assertEqual(self._fc['d'].label, 'd') - self.assertEqual(self._fc['d'].ranges, self._ranges2) - self.assertEqual(self._fc['e'].label, 'e') - self.assertEqual(self._fc['e'].ranges, self._ranges3) + self.assertEqual(self._fc["c"].label, "c") + self.assertEqual(self._fc["c"].ranges, self._ranges1) + self.assertEqual(self._fc["d"].label, "d") + self.assertEqual(self._fc["d"].ranges, self._ranges2) + self.assertEqual(self._fc["e"].label, "e") + self.assertEqual(self._fc["e"].ranges, self._ranges3) def test_const_iadd(self): with self.assertRaises(TypeError): - self._fc_const += [('d', self._ranges2), ('e', self._ranges3)] + self._fc_const += [("d", self._ranges2), ("e", self._ranges3)] def test_bool_op(self): self.assertFalse(self._fc) - self._fc.add_mapping('a', self._ranges1) + self._fc.add_mapping("a", self._ranges1) self.assertTrue(self._fc) def test_len(self): - self._fc.add_mapping('a', self._ranges1) - self._fc.add_mapping('b', self._ranges2) - self._fc.add_mapping('c', self._ranges3) + self._fc.add_mapping("a", self._ranges1) + self._fc.add_mapping("b", self._ranges2) + self._fc.add_mapping("c", self._ranges3) self.assertEqual(len(self._fc), 3) def test_getitem(self): - self._fc.add_mapping('a', self._ranges1) - self._fc.add_mapping('b', self._ranges2) - self._fc.add_mapping('c', self._ranges3) - mapping = self._fc['a'] - self.assertEqual(mapping.label, 'a') + self._fc.add_mapping("a", self._ranges1) + self._fc.add_mapping("b", self._ranges2) + self._fc.add_mapping("c", self._ranges3) + mapping = self._fc["a"] + self.assertEqual(mapping.label, "a") self.assertEqual(mapping.ranges, self._ranges1) self.assertIs(type(mapping), self._MAPPING_CLASS) self.assertIs(type(mapping.ranges), self._CONST_RANGE_SET_CLASS) def test_getitem_nonexistent(self): with self.assertRaises(KeyError): - self._fc['doesnotexist'] + self._fc["doesnotexist"] def test_iter(self): - self._fc.add_mapping('a', self._ranges1) - self._fc.add_mapping('b', self._ranges2) - self._fc.add_mapping('c', self._ranges3) + self._fc.add_mapping("a", self._ranges1) + self._fc.add_mapping("b", self._ranges2) + self._fc.add_mapping("c", self._ranges3) # This exercises iteration. labels = sorted(self._fc) - self.assertEqual(labels, ['a', 'b', 'c']) + self.assertEqual(labels, ["a", "b", "c"]) def test_find_by_value(self): - self._fc.add_mapping('a', self._ranges1) - self._fc.add_mapping('b', self._ranges2) - self._fc.add_mapping('c', self._ranges3) + self._fc.add_mapping("a", self._ranges1) + self._fc.add_mapping("b", self._ranges2) + self._fc.add_mapping("c", self._ranges3) mappings = self._fc.mappings_for_value(self._value_in_range_1_and_3) labels = set([mapping.label for mapping in mappings]) - expected_labels = set(['a', 'c']) + expected_labels = set(["a", "c"]) self.assertEqual(labels, expected_labels) @@ -451,7 +451,7 @@ class SignedEnumerationFieldClassTestCase( class StringFieldClassTestCase(_TestFieldClass, unittest.TestCase): @staticmethod def _const_value_setter(field): - field.value = 'chaine' + field.value = "chaine" def _create_field_class(self, *args, **kwargs): tc = get_default_trace_class() @@ -484,14 +484,14 @@ class _TestElementContainer: def test_append_element(self): int_field_class = self._tc.create_signed_integer_field_class(32) - self._append_element_method(self._fc, 'int32', int_field_class) - field_class = self._fc['int32'].field_class + self._append_element_method(self._fc, "int32", int_field_class) + field_class = self._fc["int32"].field_class self.assertEqual(field_class.addr, int_field_class.addr) def test_append_element_kwargs(self): int_field_class = self._tc.create_signed_integer_field_class(32) - self._append_element_method(self._fc, name='int32', field_class=int_field_class) - field_class = self._fc['int32'].field_class + self._append_element_method(self._fc, name="int32", field_class=int_field_class) + field_class = self._fc["int32"].field_class self.assertEqual(field_class.addr, int_field_class.addr) def test_append_element_invalid_name(self): @@ -502,59 +502,59 @@ class _TestElementContainer: def test_append_element_invalid_field_class(self): with self.assertRaises(TypeError): - self._append_element_method(self._fc, 'yes', object()) + self._append_element_method(self._fc, "yes", object()) def test_append_element_dup_name(self): sub_fc1 = self._tc.create_string_field_class() sub_fc2 = self._tc.create_string_field_class() with self.assertRaises(ValueError): - self._append_element_method(self._fc, 'yes', sub_fc1) - self._append_element_method(self._fc, 'yes', sub_fc2) + self._append_element_method(self._fc, "yes", sub_fc1) + self._append_element_method(self._fc, "yes", sub_fc2) def test_attr_field_class(self): int_field_class = self._tc.create_signed_integer_field_class(32) - self._append_element_method(self._fc, 'int32', int_field_class) - field_class = self._fc['int32'].field_class + self._append_element_method(self._fc, "int32", int_field_class) + field_class = self._fc["int32"].field_class self.assertIs(type(field_class), bt2_field_class._SignedIntegerFieldClass) def test_const_attr_field_class(self): int_field_class = self._tc.create_signed_integer_field_class(32) - self._append_element_method(self._fc, 'int32', int_field_class) - field_class = self._fc['int32'].field_class + self._append_element_method(self._fc, "int32", int_field_class) + field_class = self._fc["int32"].field_class const_fc = _create_const_field_class( self._tc, self._fc, self._const_value_setter ) - field_class = const_fc['int32'].field_class + field_class = const_fc["int32"].field_class self.assertIs(type(field_class), bt2_field_class._SignedIntegerFieldClassConst) def test_iadd(self): a_field_class = self._tc.create_single_precision_real_field_class() b_field_class = self._tc.create_signed_integer_field_class(17) - self._append_element_method(self._fc, 'a_float', a_field_class) - self._append_element_method(self._fc, 'b_int', b_field_class) + self._append_element_method(self._fc, "a_float", a_field_class) + self._append_element_method(self._fc, "b_int", b_field_class) c_field_class = self._tc.create_string_field_class() d_field_class = self._tc.create_signed_enumeration_field_class( field_value_range=32 ) e_field_class = self._tc.create_structure_field_class() self._fc += [ - ('c_string', c_field_class), - ('d_enum', d_field_class), - ('e_struct', e_field_class), + ("c_string", c_field_class), + ("d_enum", d_field_class), + ("e_struct", e_field_class), ] - self.assertEqual(self._fc['a_float'].field_class.addr, a_field_class.addr) - self.assertEqual(self._fc['a_float'].name, 'a_float') - self.assertEqual(self._fc['b_int'].field_class.addr, b_field_class.addr) - self.assertEqual(self._fc['b_int'].name, 'b_int') - self.assertEqual(self._fc['c_string'].field_class.addr, c_field_class.addr) - self.assertEqual(self._fc['c_string'].name, 'c_string') - self.assertEqual(self._fc['d_enum'].field_class.addr, d_field_class.addr) - self.assertEqual(self._fc['d_enum'].name, 'd_enum') - self.assertEqual(self._fc['e_struct'].field_class.addr, e_field_class.addr) - self.assertEqual(self._fc['e_struct'].name, 'e_struct') + self.assertEqual(self._fc["a_float"].field_class.addr, a_field_class.addr) + self.assertEqual(self._fc["a_float"].name, "a_float") + self.assertEqual(self._fc["b_int"].field_class.addr, b_field_class.addr) + self.assertEqual(self._fc["b_int"].name, "b_int") + self.assertEqual(self._fc["c_string"].field_class.addr, c_field_class.addr) + self.assertEqual(self._fc["c_string"].name, "c_string") + self.assertEqual(self._fc["d_enum"].field_class.addr, d_field_class.addr) + self.assertEqual(self._fc["d_enum"].name, "d_enum") + self.assertEqual(self._fc["e_struct"].field_class.addr, e_field_class.addr) + self.assertEqual(self._fc["e_struct"].name, "e_struct") def test_const_iadd(self): a_field_class = self._tc.create_single_precision_real_field_class() @@ -563,24 +563,24 @@ class _TestElementContainer: def test_bool_op(self): self.assertFalse(self._fc) - self._append_element_method(self._fc, 'a', self._tc.create_string_field_class()) + self._append_element_method(self._fc, "a", self._tc.create_string_field_class()) self.assertTrue(self._fc) def test_len(self): - self._append_element_method(self._fc, 'a', self._tc.create_string_field_class()) - self._append_element_method(self._fc, 'b', self._tc.create_string_field_class()) - self._append_element_method(self._fc, 'c', self._tc.create_string_field_class()) + self._append_element_method(self._fc, "a", self._tc.create_string_field_class()) + self._append_element_method(self._fc, "b", self._tc.create_string_field_class()) + self._append_element_method(self._fc, "c", self._tc.create_string_field_class()) self.assertEqual(len(self._fc), 3) def test_getitem(self): a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() - self._append_element_method(self._fc, 'a', a_fc) - self._append_element_method(self._fc, 'b', b_fc) - self._append_element_method(self._fc, 'c', c_fc) - self.assertEqual(self._fc['b'].field_class.addr, b_fc.addr) - self.assertEqual(self._fc['b'].name, 'b') + self._append_element_method(self._fc, "a", a_fc) + self._append_element_method(self._fc, "b", b_fc) + self._append_element_method(self._fc, "c", c_fc) + self.assertEqual(self._fc["b"].field_class.addr, b_fc.addr) + self.assertEqual(self._fc["b"].name, "b") def test_getitem_invalid_key_type(self): with self.assertRaises(TypeError): @@ -588,18 +588,18 @@ class _TestElementContainer: def test_getitem_invalid_key(self): with self.assertRaises(KeyError): - self._fc['no way'] + self._fc["no way"] def test_contains(self): - self.assertFalse('a' in self._fc) - self._append_element_method(self._fc, 'a', self._tc.create_string_field_class()) - self.assertTrue('a' in self._fc) + self.assertFalse("a" in self._fc) + self._append_element_method(self._fc, "a", self._tc.create_string_field_class()) + self.assertTrue("a" in self._fc) def test_iter(self): a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() - elements = (('a', a_fc), ('b', b_fc), ('c', c_fc)) + elements = (("a", a_fc), ("b", b_fc), ("c", c_fc)) for elem in elements: self._append_element_method(self._fc, *elem) @@ -614,24 +614,24 @@ class _TestElementContainer: a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() - self._append_element_method(self._fc, 'c', c_fc) - self._append_element_method(self._fc, 'a', a_fc) - self._append_element_method(self._fc, 'b', b_fc) + self._append_element_method(self._fc, "c", c_fc) + self._append_element_method(self._fc, "a", a_fc) + self._append_element_method(self._fc, "b", b_fc) elem = self._at_index_method(self._fc, 1) self.assertEqual(elem.field_class.addr, a_fc.addr) - self.assertEqual(elem.name, 'a') + self.assertEqual(elem.name, "a") def test_at_index_invalid(self): self._append_element_method( - self._fc, 'c', self._tc.create_signed_integer_field_class(32) + self._fc, "c", self._tc.create_signed_integer_field_class(32) ) with self.assertRaises(TypeError): - self._at_index_method(self._fc, 'yes') + self._at_index_method(self._fc, "yes") def test_at_index_out_of_bounds_after(self): self._append_element_method( - self._fc, 'c', self._tc.create_signed_integer_field_class(32) + self._fc, "c", self._tc.create_signed_integer_field_class(32) ) with self.assertRaises(IndexError): @@ -640,19 +640,19 @@ class _TestElementContainer: def test_user_attributes(self): self._append_element_method( self._fc, - 'c', + "c", self._tc.create_string_field_class(), - user_attributes={'salut': 23}, + user_attributes={"salut": 23}, ) - self.assertEqual(self._fc['c'].user_attributes, {'salut': 23}) + self.assertEqual(self._fc["c"].user_attributes, {"salut": 23}) self.assertIs(type(self._fc.user_attributes), bt2_value.MapValue) - self.assertIs(type(self._fc['c'].user_attributes), bt2_value.MapValue) + self.assertIs(type(self._fc["c"].user_attributes), bt2_value.MapValue) def test_invalid_user_attributes(self): with self.assertRaises(TypeError): self._append_element_method( self._fc, - 'c', + "c", self._tc.create_string_field_class(), user_attributes=object(), ) @@ -660,7 +660,7 @@ class _TestElementContainer: def test_invalid_user_attributes_value_type(self): with self.assertRaises(TypeError): self._append_element_method( - self._fc, 'c', self._tc.create_string_field_class(), user_attributes=23 + self._fc, "c", self._tc.create_string_field_class(), user_attributes=23 ) @@ -687,16 +687,16 @@ class StructureFieldClassTestCase( def test_const_member_field_class(self): def _real_value_setter(field): - field.value = {'real': 0} + field.value = {"real": 0} tc = get_default_trace_class() fc = tc.create_structure_field_class() member_fc = self._tc.create_single_precision_real_field_class() - fc.append_member('real', member_fc) + fc.append_member("real", member_fc) const_fc = _create_const_field_class(tc, fc, _real_value_setter) self.assertIs( - type(const_fc['real'].field_class), + type(const_fc["real"].field_class), bt2_field_class._SinglePrecisionRealFieldClassConst, ) @@ -704,10 +704,10 @@ class StructureFieldClassTestCase( tc = get_default_trace_class() fc = tc.create_structure_field_class() member_fc = self._tc.create_single_precision_real_field_class() - fc.append_member('real', member_fc) + fc.append_member("real", member_fc) self.assertIs( - type(fc['real'].field_class), bt2_field_class._SinglePrecisionRealFieldClass + type(fc["real"].field_class), bt2_field_class._SinglePrecisionRealFieldClass ) @@ -755,19 +755,19 @@ class OptionWithoutSelectorFieldClassTestCase(_TestFieldClass, unittest.TestCase class _OptionWithSelectorFieldClassTestCase(_TestFieldClass): @staticmethod def _const_value_setter(field): - field['opt'].has_field = True - field['opt'].value = 12 + field["opt"].has_field = True + field["opt"].value = 12 def _create_default_const_field_class(self, *args, **kwargs): # Create a struct to contain the option and its selector else we can't # create the non-const field necessary to get the the const field_class struct_fc = self._tc.create_structure_field_class() - struct_fc.append_member('selecteux', self._tag_fc) + struct_fc.append_member("selecteux", self._tag_fc) opt_fc = self._create_default_field_class(*args, **kwargs) - struct_fc.append_member('opt', opt_fc) + struct_fc.append_member("opt", opt_fc) return _create_const_field_class(self._tc, struct_fc, self._const_value_setter)[ - 'opt' + "opt" ].field_class def setUp(self): @@ -783,18 +783,18 @@ class _OptionWithSelectorFieldClassTestCase(_TestFieldClass): baz_fc = self._tc.create_string_field_class() inner_struct_fc = self._tc.create_structure_field_class() - inner_struct_fc.append_member('bar', bar_fc) - inner_struct_fc.append_member('baz', baz_fc) - inner_struct_fc.append_member('tag', self._tag_fc) - inner_struct_fc.append_member('opt', fc) + inner_struct_fc.append_member("bar", bar_fc) + inner_struct_fc.append_member("baz", baz_fc) + inner_struct_fc.append_member("tag", self._tag_fc) + inner_struct_fc.append_member("opt", fc) opt_struct_array_fc = self._tc.create_option_without_selector_field_class( inner_struct_fc ) outer_struct_fc = self._tc.create_structure_field_class() - outer_struct_fc.append_member('foo', foo_fc) - outer_struct_fc.append_member('inner_opt', opt_struct_array_fc) + outer_struct_fc.append_member("foo", foo_fc) + outer_struct_fc.append_member("inner_opt", opt_struct_array_fc) # The path to the selector field class is resolved when the # option field class is actually used, for example in a packet @@ -937,7 +937,7 @@ class VariantFieldClassWithoutSelectorTestCase( tc = get_default_trace_class() fc = tc.create_variant_field_class(*args, **kwargs) int_field_class = self._tc.create_signed_integer_field_class(32) - fc.append_option('int32', int_field_class) + fc.append_option("int32", int_field_class) return _create_const_field_class(tc, fc, self._const_value_setter) @@ -947,8 +947,8 @@ class VariantFieldClassWithoutSelectorTestCase( class _VariantFieldClassWithIntegerSelectorTestCase: @staticmethod def _const_value_setter(field): - field['variant'].selected_option_index = 0 - field['variant'] = 12 + field["variant"].selected_option_index = 0 + field["variant"] = 12 def _create_default_field_class(self, *args, **kwargs): return self._tc.create_variant_field_class( @@ -959,17 +959,17 @@ class _VariantFieldClassWithIntegerSelectorTestCase: # Create a struct to contain the variant and its selector else we can't # create the non-const field necessary to get the the const field_class struct_fc = self._tc.create_structure_field_class() - struct_fc.append_member('selecteux', self._selector_fc) + struct_fc.append_member("selecteux", self._selector_fc) variant_fc = self._tc.create_variant_field_class( *args, selector_fc=self._selector_fc ) variant_fc.append_option( - 'a', self._tc.create_signed_integer_field_class(32), self._ranges1 + "a", self._tc.create_signed_integer_field_class(32), self._ranges1 ) - struct_fc.append_member('variant', variant_fc, **kwargs) + struct_fc.append_member("variant", variant_fc, **kwargs) return _create_const_field_class(self._tc, struct_fc, self._const_value_setter)[ - 'variant' + "variant" ].field_class def setUp(self): @@ -983,26 +983,26 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_append_element(self): str_field_class = self._tc.create_string_field_class() - self._fc.append_option('str', str_field_class, self._ranges1) - opt = self._fc['str'] + self._fc.append_option("str", str_field_class, self._ranges1) + opt = self._fc["str"] self.assertEqual(opt.field_class.addr, str_field_class.addr) - self.assertEqual(opt.name, 'str') + self.assertEqual(opt.name, "str") self.assertEqual(opt.ranges.addr, self._ranges1.addr) def test_const_append(self): fc_const = self._create_default_const_field_class() str_field_class = self._tc.create_string_field_class() with self.assertRaises(AttributeError): - fc_const.append_option('str', str_field_class, self._ranges1) + fc_const.append_option("str", str_field_class, self._ranges1) def test_append_element_kwargs(self): int_field_class = self._tc.create_signed_integer_field_class(32) self._fc.append_option( - name='int32', field_class=int_field_class, ranges=self._ranges1 + name="int32", field_class=int_field_class, ranges=self._ranges1 ) - opt = self._fc['int32'] + opt = self._fc["int32"] self.assertEqual(opt.field_class.addr, int_field_class.addr) - self.assertEqual(opt.name, 'int32') + self.assertEqual(opt.name, "int32") self.assertEqual(opt.ranges.addr, self._ranges1.addr) def test_append_element_invalid_name(self): @@ -1013,21 +1013,21 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_append_element_invalid_field_class(self): with self.assertRaises(TypeError): - self._fc.append_option(self._fc, 'yes', object()) + self._fc.append_option(self._fc, "yes", object()) def test_append_element_invalid_ranges(self): sub_fc = self._tc.create_string_field_class() with self.assertRaises(TypeError): - self._fc.append_option(self._fc, sub_fc, 'lel') + self._fc.append_option(self._fc, sub_fc, "lel") def test_append_element_dup_name(self): sub_fc1 = self._tc.create_string_field_class() sub_fc2 = self._tc.create_string_field_class() with self.assertRaises(ValueError): - self._fc.append_option('yes', sub_fc1, self._ranges1) - self._fc.append_option('yes', sub_fc2, self._ranges2) + self._fc.append_option("yes", sub_fc1, self._ranges1) + self._fc.append_option("yes", sub_fc2, self._ranges2) def test_append_element_invalid_ranges_signedness(self): sub_fc = self._tc.create_string_field_class() @@ -1037,12 +1037,12 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_user_attributes(self): self._fc.append_option( - 'c', + "c", self._tc.create_string_field_class(), self._ranges1, - user_attributes={'salut': 23}, + user_attributes={"salut": 23}, ) - self.assertEqual(self._fc['c'].user_attributes, {'salut': 23}) + self.assertEqual(self._fc["c"].user_attributes, {"salut": 23}) self.assertIs(type(self._fc.user_attributes), bt2_value.MapValue) def test_const_user_attributes(self): @@ -1052,7 +1052,7 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_invalid_user_attributes(self): with self.assertRaises(TypeError): self._fc.append_option( - 'c', + "c", self._tc.create_string_field_class(), self._ranges1, user_attributes=object(), @@ -1061,7 +1061,7 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_invalid_user_attributes_value_type(self): with self.assertRaises(TypeError): self._fc.append_option( - 'c', + "c", self._tc.create_string_field_class(), self._ranges1, user_attributes=23, @@ -1069,64 +1069,64 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_iadd(self): a_field_class = self._tc.create_single_precision_real_field_class() - self._fc.append_option('a_float', a_field_class, self._ranges1) + self._fc.append_option("a_float", a_field_class, self._ranges1) c_field_class = self._tc.create_string_field_class() d_field_class = self._tc.create_signed_enumeration_field_class( field_value_range=32 ) self._fc += [ - ('c_string', c_field_class, self._ranges2), - ('d_enum', d_field_class, self._ranges3), + ("c_string", c_field_class, self._ranges2), + ("d_enum", d_field_class, self._ranges3), ] - self.assertEqual(self._fc['a_float'].field_class.addr, a_field_class.addr) - self.assertEqual(self._fc['a_float'].name, 'a_float') - self.assertEqual(self._fc['a_float'].ranges, self._ranges1) - self.assertEqual(self._fc['c_string'].field_class.addr, c_field_class.addr) - self.assertEqual(self._fc['c_string'].name, 'c_string') - self.assertEqual(self._fc['c_string'].ranges, self._ranges2) - self.assertEqual(self._fc['d_enum'].field_class.addr, d_field_class.addr) - self.assertEqual(self._fc['d_enum'].name, 'd_enum') - self.assertEqual(self._fc['d_enum'].ranges, self._ranges3) + self.assertEqual(self._fc["a_float"].field_class.addr, a_field_class.addr) + self.assertEqual(self._fc["a_float"].name, "a_float") + self.assertEqual(self._fc["a_float"].ranges, self._ranges1) + self.assertEqual(self._fc["c_string"].field_class.addr, c_field_class.addr) + self.assertEqual(self._fc["c_string"].name, "c_string") + self.assertEqual(self._fc["c_string"].ranges, self._ranges2) + self.assertEqual(self._fc["d_enum"].field_class.addr, d_field_class.addr) + self.assertEqual(self._fc["d_enum"].name, "d_enum") + self.assertEqual(self._fc["d_enum"].ranges, self._ranges3) def test_const_iadd(self): fc_const = self._create_default_const_field_class() a_field_class = self._tc.create_single_precision_real_field_class() with self.assertRaises(TypeError): - fc_const += [('a_float', a_field_class, self._ranges1)] + fc_const += [("a_float", a_field_class, self._ranges1)] def test_bool_op(self): self.assertFalse(self._fc) - self._fc.append_option('a', self._tc.create_string_field_class(), self._ranges1) + self._fc.append_option("a", self._tc.create_string_field_class(), self._ranges1) self.assertTrue(self._fc) def test_len(self): - self._fc.append_option('a', self._tc.create_string_field_class(), self._ranges1) - self._fc.append_option('b', self._tc.create_string_field_class(), self._ranges2) - self._fc.append_option('c', self._tc.create_string_field_class(), self._ranges3) + self._fc.append_option("a", self._tc.create_string_field_class(), self._ranges1) + self._fc.append_option("b", self._tc.create_string_field_class(), self._ranges2) + self._fc.append_option("c", self._tc.create_string_field_class(), self._ranges3) self.assertEqual(len(self._fc), 3) def test_getitem(self): a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() - self._fc.append_option('a', a_fc, self._ranges1) - self._fc.append_option('b', b_fc, self._ranges2) - self._fc.append_option('c', c_fc, self._ranges3) - self.assertEqual(self._fc['b'].field_class.addr, b_fc.addr) - self.assertEqual(self._fc['b'].name, 'b') - self.assertEqual(self._fc['b'].ranges.addr, self._ranges2.addr) + self._fc.append_option("a", a_fc, self._ranges1) + self._fc.append_option("b", b_fc, self._ranges2) + self._fc.append_option("c", c_fc, self._ranges3) + self.assertEqual(self._fc["b"].field_class.addr, b_fc.addr) + self.assertEqual(self._fc["b"].name, "b") + self.assertEqual(self._fc["b"].ranges.addr, self._ranges2.addr) def test_option_field_class(self): a_fc = self._tc.create_signed_integer_field_class(32) - self._fc.append_option('a', a_fc, self._ranges1) + self._fc.append_option("a", a_fc, self._ranges1) self.assertIs( - type(self._fc['a'].field_class), bt2_field_class._SignedIntegerFieldClass + type(self._fc["a"].field_class), bt2_field_class._SignedIntegerFieldClass ) def test_const_option_field_class(self): fc_const = self._create_default_const_field_class() self.assertIs( - type(fc_const['a'].field_class), + type(fc_const["a"].field_class), bt2_field_class._SignedIntegerFieldClassConst, ) @@ -1136,21 +1136,21 @@ class _VariantFieldClassWithIntegerSelectorTestCase: def test_getitem_invalid_key(self): with self.assertRaises(KeyError): - self._fc['no way'] + self._fc["no way"] def test_contains(self): - self.assertFalse('a' in self._fc) - self._fc.append_option('a', self._tc.create_string_field_class(), self._ranges1) - self.assertTrue('a' in self._fc) + self.assertFalse("a" in self._fc) + self._fc.append_option("a", self._tc.create_string_field_class(), self._ranges1) + self.assertTrue("a" in self._fc) def test_iter(self): a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() opts = ( - ('a', a_fc, self._ranges1), - ('b', b_fc, self._ranges2), - ('c', c_fc, self._ranges3), + ("a", a_fc, self._ranges1), + ("b", b_fc, self._ranges2), + ("c", c_fc, self._ranges3), ) for opt in opts: @@ -1166,24 +1166,24 @@ class _VariantFieldClassWithIntegerSelectorTestCase: a_fc = self._tc.create_signed_integer_field_class(32) b_fc = self._tc.create_string_field_class() c_fc = self._tc.create_single_precision_real_field_class() - self._fc.append_option('c', c_fc, self._ranges1) - self._fc.append_option('a', a_fc, self._ranges2) - self._fc.append_option('b', b_fc, self._ranges3) + self._fc.append_option("c", c_fc, self._ranges1) + self._fc.append_option("a", a_fc, self._ranges2) + self._fc.append_option("b", b_fc, self._ranges3) self.assertEqual(self._fc.option_at_index(1).field_class.addr, a_fc.addr) - self.assertEqual(self._fc.option_at_index(1).name, 'a') + self.assertEqual(self._fc.option_at_index(1).name, "a") self.assertEqual(self._fc.option_at_index(1).ranges.addr, self._ranges2.addr) def test_at_index_invalid(self): self._fc.append_option( - 'c', self._tc.create_signed_integer_field_class(32), self._ranges3 + "c", self._tc.create_signed_integer_field_class(32), self._ranges3 ) with self.assertRaises(TypeError): - self._fc.option_at_index('yes') + self._fc.option_at_index("yes") def test_at_index_out_of_bounds_after(self): self._fc.append_option( - 'c', self._tc.create_signed_integer_field_class(32), self._ranges3 + "c", self._tc.create_signed_integer_field_class(32), self._ranges3 ) with self.assertRaises(IndexError): @@ -1206,13 +1206,13 @@ class _VariantFieldClassWithIntegerSelectorTestCase: # } inner_struct[2]; # }; self._fc.append_option( - 'a', self._tc.create_single_precision_real_field_class(), self._ranges1 + "a", self._tc.create_single_precision_real_field_class(), self._ranges1 ) self._fc.append_option( - 'b', self._tc.create_signed_integer_field_class(21), self._ranges2 + "b", self._tc.create_signed_integer_field_class(21), self._ranges2 ) self._fc.append_option( - 'c', self._tc.create_unsigned_integer_field_class(34), self._ranges3 + "c", self._tc.create_unsigned_integer_field_class(34), self._ranges3 ) foo_fc = self._tc.create_single_precision_real_field_class() @@ -1220,18 +1220,18 @@ class _VariantFieldClassWithIntegerSelectorTestCase: baz_fc = self._tc.create_string_field_class() inner_struct_fc = self._tc.create_structure_field_class() - inner_struct_fc.append_member('selector', self._selector_fc) - inner_struct_fc.append_member('bar', bar_fc) - inner_struct_fc.append_member('baz', baz_fc) - inner_struct_fc.append_member('variant', self._fc) + inner_struct_fc.append_member("selector", self._selector_fc) + inner_struct_fc.append_member("bar", bar_fc) + inner_struct_fc.append_member("baz", baz_fc) + inner_struct_fc.append_member("variant", self._fc) inner_struct_array_fc = self._tc.create_static_array_field_class( inner_struct_fc, 2 ) outer_struct_fc = self._tc.create_structure_field_class() - outer_struct_fc.append_member('foo', foo_fc) - outer_struct_fc.append_member('inner_struct', inner_struct_array_fc) + outer_struct_fc.append_member("foo", foo_fc) + outer_struct_fc.append_member("inner_struct", inner_struct_array_fc) # The path to the selector field is resolved when the sequence is # actually used, for example in a packet context. @@ -1339,7 +1339,7 @@ class StaticArrayFieldClassTestCase( def test_create_invalid_length_type(self): with self.assertRaises(TypeError): self._tc.create_static_array_field_class( - self._tc.create_string_field_class(), 'the length' + self._tc.create_string_field_class(), "the length" ) @@ -1412,18 +1412,18 @@ class DynamicArrayWithLengthFieldFieldClassTestCase( baz_fc = self._tc.create_string_field_class() inner_struct_fc = self._tc.create_structure_field_class() - inner_struct_fc.append_member('bar', bar_fc) - inner_struct_fc.append_member('baz', baz_fc) - inner_struct_fc.append_member('len', self._len_fc) - inner_struct_fc.append_member('dyn_array', fc) + inner_struct_fc.append_member("bar", bar_fc) + inner_struct_fc.append_member("baz", baz_fc) + inner_struct_fc.append_member("len", self._len_fc) + inner_struct_fc.append_member("dyn_array", fc) inner_struct_array_fc = self._tc.create_static_array_field_class( inner_struct_fc, 2 ) outer_struct_fc = self._tc.create_structure_field_class() - outer_struct_fc.append_member('foo', foo_fc) - outer_struct_fc.append_member('inner_struct', inner_struct_array_fc) + outer_struct_fc.append_member("foo", foo_fc) + outer_struct_fc.append_member("inner_struct", inner_struct_array_fc) # The path to the length field is resolved when the sequence is # actually used, for example in a packet context. diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index dfaa6934..acf283ce 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -16,17 +16,17 @@ class _MyIter(bt2._UserMessageIterator): self._tc = self._component._create_trace_class() self._t = self._tc() self._sc = self._tc.create_stream_class(supports_packets=True) - self._ec = self._sc.create_event_class(name='salut') + self._ec = self._sc.create_event_class(name="salut") self._my_int_ft = self._tc.create_signed_integer_field_class(32) payload_ft = self._tc.create_structure_field_class() - payload_ft += [('my_int', self._my_int_ft)] + payload_ft += [("my_int", self._my_int_ft)] self._ec.payload_field_type = payload_ft self._stream = self._t.create_stream(self._sc) self._packet = self._stream.create_packet() def _create_event(self, value): ev = self._ec() - ev.payload_field['my_int'] = value + ev.payload_field["my_int"] = value ev.packet = self._packet return ev @@ -46,10 +46,10 @@ class GraphTestCase(unittest.TestCase): def test_create_invalid_mip_version_type(self): with self.assertRaises(TypeError): - bt2.Graph('') + bt2.Graph("") def test_create_unknown_mip_version(self): - with self.assertRaisesRegex(ValueError, 'unknown MIP version'): + with self.assertRaisesRegex(ValueError, "unknown MIP version"): bt2.Graph(1) def test_default_interrupter(self): @@ -61,18 +61,18 @@ class GraphTestCase(unittest.TestCase): def _user_consume(self): pass - comp = self._graph.add_component(MySink, 'salut') - self.assertEqual(comp.name, 'salut') + comp = self._graph.add_component(MySink, "salut") + self.assertEqual(comp.name, "salut") def test_add_component_gen_cls(self): class MySink(bt2._UserSinkComponent): def _user_consume(self): pass - comp = self._graph.add_component(MySink, 'salut') + comp = self._graph.add_component(MySink, "salut") assert comp - comp2 = self._graph.add_component(comp.cls, 'salut2') - self.assertEqual(comp2.name, 'salut2') + comp2 = self._graph.add_component(comp.cls, "salut2") + self.assertEqual(comp2.name, "salut2") def test_add_component_params(self): comp_params = None @@ -85,8 +85,8 @@ class GraphTestCase(unittest.TestCase): def _user_consume(self): pass - params = {'hello': 23, 'path': '/path/to/stuff'} - self._graph.add_component(MySink, 'salut', params) + params = {"hello": 23, "path": "/path/to/stuff"} + self._graph.add_component(MySink, "salut", params) self.assertEqual(params, comp_params) del comp_params @@ -102,7 +102,7 @@ class GraphTestCase(unittest.TestCase): pass obj = object() - self._graph.add_component(MySink, 'salut', obj=obj) + self._graph.add_component(MySink, "salut", obj=obj) self.assertIs(comp_obj, obj) del comp_obj @@ -117,22 +117,22 @@ class GraphTestCase(unittest.TestCase): def _user_consume(self): pass - self._graph.add_component(MySink, 'salut') + self._graph.add_component(MySink, "salut") self.assertIsNone(comp_obj) del comp_obj def test_add_component_obj_non_python_comp_cls(self): - plugin = bt2.find_plugin('text', find_in_user_dir=False, find_in_sys_dir=False) + plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False) assert plugin is not None - cc = plugin.source_component_classes['dmesg'] + cc = plugin.source_component_classes["dmesg"] assert cc is not None with self.assertRaises(ValueError): - self._graph.add_component(cc, 'salut', obj=57) + self._graph.add_component(cc, "salut", obj=57) def test_add_component_invalid_cls_type(self): with self.assertRaises(TypeError): - self._graph.add_component(int, 'salut') + self._graph.add_component(int, "salut") def test_add_component_invalid_logging_level_type(self): class MySink(bt2._UserSinkComponent): @@ -140,7 +140,7 @@ class GraphTestCase(unittest.TestCase): pass with self.assertRaises(TypeError): - self._graph.add_component(MySink, 'salut', logging_level='yo') + self._graph.add_component(MySink, "salut", logging_level="yo") def test_add_component_invalid_logging_level_value(self): class MySink(bt2._UserSinkComponent): @@ -148,7 +148,7 @@ class GraphTestCase(unittest.TestCase): pass with self.assertRaises(ValueError): - self._graph.add_component(MySink, 'salut', logging_level=12345) + self._graph.add_component(MySink, "salut", logging_level=12345) def test_add_component_invalid_params_type(self): class MySink(bt2._UserSinkComponent): @@ -156,7 +156,7 @@ class GraphTestCase(unittest.TestCase): pass with self.assertRaises(TypeError): - self._graph.add_component(MySink, 'salut', params=12) + self._graph.add_component(MySink, "salut", params=12) def test_add_component_params_dict(self): params_obj = None @@ -169,8 +169,8 @@ class GraphTestCase(unittest.TestCase): def _user_consume(self): pass - params = {'plage': 12312} - self._graph.add_component(MySink, 'salut', params=params) + params = {"plage": 12312} + self._graph.add_component(MySink, "salut", params=params) # Check equality and not identity because `add_component()` method # converts the Python `dict` to a `bt2.MapValue`. @@ -187,8 +187,8 @@ class GraphTestCase(unittest.TestCase): def _user_consume(self): pass - params = bt2.MapValue({'beachclub': '121'}) - self._graph.add_component(MySink, 'salut', params=params) + params = bt2.MapValue({"beachclub": "121"}) + self._graph.add_component(MySink, "salut", params=params) self.assertEqual(params, params_obj) @@ -198,7 +198,7 @@ class GraphTestCase(unittest.TestCase): pass comp = self._graph.add_component( - MySink, 'salut', logging_level=bt2.LoggingLevel.DEBUG + MySink, "salut", logging_level=bt2.LoggingLevel.DEBUG ) self.assertEqual(comp.logging_level, bt2.LoggingLevel.DEBUG) @@ -207,45 +207,45 @@ class GraphTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") conn = self._graph.connect_ports( - src.output_ports['out'], sink.input_ports['in'] + src.output_ports["out"], sink.input_ports["in"] ) - self.assertTrue(src.output_ports['out'].is_connected) - self.assertTrue(sink.input_ports['in'].is_connected) - self.assertEqual(src.output_ports['out'].connection.addr, conn.addr) - self.assertEqual(sink.input_ports['in'].connection.addr, conn.addr) + self.assertTrue(src.output_ports["out"].is_connected) + self.assertTrue(sink.input_ports["in"].is_connected) + self.assertEqual(src.output_ports["out"].connection.addr, conn.addr) + self.assertEqual(sink.input_ports["in"].connection.addr, conn.addr) def test_connect_ports_invalid_direction(self): class MySource( bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") with self.assertRaises(TypeError): - self._graph.connect_ports(sink.input_ports['in'], src.output_ports['out']) + self._graph.connect_ports(sink.input_ports["in"], src.output_ports["out"]) def test_add_interrupter(self): class MyIter(bt2._UserMessageIterator): @@ -254,25 +254,25 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): next(self._msg_iter) def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) # add two interrupters, set one of them interrupter1 = bt2.Interrupter() interrupter2 = bt2.Interrupter() self._graph.add_interrupter(interrupter1) - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) self._graph.add_interrupter(interrupter2) with self.assertRaises(bt2._Error): @@ -297,11 +297,11 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): # Pretend that somebody asynchronously interrupted the graph. @@ -310,12 +310,12 @@ class GraphTestCase(unittest.TestCase): return next(self._msg_iter) def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) graph = self._graph - up = self._graph.add_component(MySource, 'down') - down = self._graph.add_component(MySink, 'up') - self._graph.connect_ports(up.output_ports['out'], down.input_ports['in']) + up = self._graph.add_component(MySource, "down") + down = self._graph.add_component(MySink, "up") + self._graph.connect_ports(up.output_ports["out"], down.input_ports["in"]) with self.assertRaises(bt2.TryAgain): self._graph.run() @@ -342,11 +342,11 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") self._at = 0 def _user_consume(comp_self): @@ -358,7 +358,7 @@ class GraphTestCase(unittest.TestCase): self.assertIs(type(msg), bt2._PacketBeginningMessageConst) elif comp_self._at >= 2 and comp_self._at <= 6: self.assertIs(type(msg), bt2._EventMessageConst) - self.assertEqual(msg.event.cls.name, 'salut') + self.assertEqual(msg.event.cls.name, "salut") elif comp_self._at == 7: self.assertIs(type(msg), bt2._PacketEndMessageConst) elif comp_self._at == 8: @@ -369,9 +369,9 @@ class GraphTestCase(unittest.TestCase): def _user_graph_is_configured(self): self._msg_iter = self._create_message_iterator(self._input_port) - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) self._graph.run() def test_run_once(self): @@ -380,11 +380,11 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") def _user_consume(comp_self): nonlocal run_count @@ -392,9 +392,9 @@ class GraphTestCase(unittest.TestCase): raise bt2.TryAgain run_count = 0 - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) with self.assertRaises(bt2.TryAgain): self._graph.run_once() @@ -407,18 +407,18 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") def _user_consume(comp_self): raise bt2.Stop - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) with self.assertRaises(bt2.Stop): self._graph.run_once() @@ -441,11 +441,11 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") self._at = 0 def _user_consume(comp_self): @@ -465,9 +465,9 @@ class GraphTestCase(unittest.TestCase): def _user_graph_is_configured(self): self._msg_iter = self._create_message_iterator(self._input_port) - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) with self.assertRaises(bt2.TryAgain): self._graph.run() @@ -495,11 +495,11 @@ class GraphTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") self._at = 0 def _user_consume(comp_self): @@ -513,16 +513,16 @@ class GraphTestCase(unittest.TestCase): elif comp_self._at == 3: nonlocal raised_in_sink raised_in_sink = True - raise RuntimeError('error!') + raise RuntimeError("error!") comp_self._at += 1 def _user_graph_is_configured(self): self._msg_iter = self._create_message_iterator(self._input_port) - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) with self.assertRaises(bt2._Error): self._graph.run() @@ -532,18 +532,18 @@ class GraphTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') - self._add_output_port('zero') + self._add_output_port("out") + self._add_output_port("zero") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop def _user_port_connected(self, port, other_port): - self._add_input_port('taste') + self._add_input_port("taste") def port_added_listener(component, port): nonlocal calls @@ -551,45 +551,45 @@ class GraphTestCase(unittest.TestCase): calls = [] self._graph.add_port_added_listener(port_added_listener) - src = self._graph.add_component(MySource, 'src') - sink = self._graph.add_component(MySink, 'sink') - self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) + src = self._graph.add_component(MySource, "src") + sink = self._graph.add_component(MySink, "sink") + self._graph.connect_ports(src.output_ports["out"], sink.input_ports["in"]) self.assertEqual(len(calls), 4) self.assertIs(calls[0][0], port_added_listener) - self.assertEqual(calls[0][1].name, 'src') - self.assertEqual(calls[0][2].name, 'out') + self.assertEqual(calls[0][1].name, "src") + self.assertEqual(calls[0][2].name, "out") self.assertIs(calls[1][0], port_added_listener) - self.assertEqual(calls[1][1].name, 'src') - self.assertEqual(calls[1][2].name, 'zero') + self.assertEqual(calls[1][1].name, "src") + self.assertEqual(calls[1][2].name, "zero") self.assertIs(calls[2][0], port_added_listener) - self.assertEqual(calls[2][1].name, 'sink') - self.assertEqual(calls[2][2].name, 'in') + self.assertEqual(calls[2][1].name, "sink") + self.assertEqual(calls[2][2].name, "in") self.assertIs(calls[3][0], port_added_listener) - self.assertEqual(calls[3][1].name, 'sink') - self.assertEqual(calls[3][2].name, 'taste') + self.assertEqual(calls[3][1].name, "sink") + self.assertEqual(calls[3][2].name, "taste") def test_invalid_listeners(self): class MySource( bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(self, config, params, obj): - self._add_output_port('out') - self._add_output_port('zero') + self._add_output_port("out") + self._add_output_port("zero") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop def _user_port_connected(self, port, other_port): - self._add_input_port('taste') + self._add_input_port("taste") with self.assertRaises(TypeError): self._graph.add_port_added_listener(1234) @@ -597,7 +597,7 @@ class GraphTestCase(unittest.TestCase): def test_raise_in_component_init(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - raise ValueError('oops!') + raise ValueError("oops!") def _user_consume(self): raise bt2.Stop @@ -605,25 +605,25 @@ class GraphTestCase(unittest.TestCase): graph = bt2.Graph() with self.assertRaises(bt2._Error): - graph.add_component(MySink, 'comp') + graph.add_component(MySink, "comp") def test_raise_in_port_added_listener(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): raise bt2.Stop def port_added_listener(component, port): - raise ValueError('oh noes!') + raise ValueError("oh noes!") graph = bt2.Graph() graph.add_port_added_listener(port_added_listener) with self.assertRaises(bt2._Error): - graph.add_component(MySink, 'comp') + graph.add_component(MySink, "comp") -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_integer_range_set.py b/tests/bindings/python/bt2/test_integer_range_set.py index 9205c658..808a4045 100644 --- a/tests/bindings/python/bt2/test_integer_range_set.py +++ b/tests/bindings/python/bt2/test_integer_range_set.py @@ -15,9 +15,9 @@ def get_const_signed_integer_range(int_ranges): tc = get_default_trace_class() fc = tc.create_signed_enumeration_field_class(32) - fc.add_mapping('something', bt2.SignedIntegerRangeSet(int_ranges)) + fc.add_mapping("something", bt2.SignedIntegerRangeSet(int_ranges)) - return create_const_field(tc, fc, range_setter).cls['something'].ranges + return create_const_field(tc, fc, range_setter).cls["something"].ranges def get_const_unsigned_integer_range(int_ranges): @@ -26,9 +26,9 @@ def get_const_unsigned_integer_range(int_ranges): tc = get_default_trace_class() fc = tc.create_unsigned_enumeration_field_class(32) - fc.add_mapping('something', bt2.UnsignedIntegerRangeSet(int_ranges)) + fc.add_mapping("something", bt2.UnsignedIntegerRangeSet(int_ranges)) - return create_const_field(tc, fc, range_setter).cls['something'].ranges + return create_const_field(tc, fc, range_setter).cls["something"].ranges class _IntegerRangeTestCase: @@ -90,7 +90,7 @@ class _IntegerRangeTestCase: def test_contains_wrong_type(self): with self.assertRaises(TypeError): - self._rg.contains('allo') + self._rg.contains("allo") def test_contains_out_of_bound(self): with self.assertRaises(ValueError): @@ -186,7 +186,7 @@ class _IntegerRangeSetTestCase: def test_create_wrong_elem_type(self): with self.assertRaises(TypeError): - self._rs = self._CLS((self._range1, self._range2, 'lel')) + self._rs = self._CLS((self._range1, self._range2, "lel")) def test_len(self): self.assertEqual(len(self._rs), 3) @@ -205,7 +205,7 @@ class _IntegerRangeSetTestCase: def test_contains_value_wrong_type(self): with self.assertRaises(TypeError): - self._rs.contains_value('meow') + self._rs.contains_value("meow") def test_iter(self): range_list = list(self._rs) @@ -299,5 +299,5 @@ class SignedIntegerRangeSetTestCase(_IntegerRangeSetTestCase, unittest.TestCase) super().setUp() -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_interrupter.py b/tests/bindings/python/bt2/test_interrupter.py index 0cd03067..636c03e4 100644 --- a/tests/bindings/python/bt2/test_interrupter.py +++ b/tests/bindings/python/bt2/test_interrupter.py @@ -34,5 +34,5 @@ class InterrupterTestCase(unittest.TestCase): self.assertFalse(self._interrupter) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_message.py b/tests/bindings/python/bt2/test_message.py index fc75e1c5..11d12a02 100644 --- a/tests/bindings/python/bt2/test_message.py +++ b/tests/bindings/python/bt2/test_message.py @@ -24,7 +24,7 @@ class AllMessagesTestCase(unittest.TestCase): def __init__(self, config, self_port_output): self._at = 0 self._with_stream_msgs_clock_snapshots = self_port_output.user_data.get( - 'with_stream_msgs_clock_snapshots', False + "with_stream_msgs_clock_snapshots", False ) def __next__(self): @@ -107,9 +107,9 @@ class AllMessagesTestCase(unittest.TestCase): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out', params) + self._add_output_port("out", params) - with_cc = bool(params['with_cc']) + with_cc = bool(params["with_cc"]) tc = self._create_trace_class() if with_cc: cc = self._create_clock_class() @@ -130,15 +130,15 @@ class AllMessagesTestCase(unittest.TestCase): # Create payload field class my_int_fc = tc.create_signed_integer_field_class(32) payload_fc = tc.create_structure_field_class() - payload_fc += [('my_int', my_int_fc)] + payload_fc += [("my_int", my_int_fc)] # Create specific context field class my_int_fc = tc.create_signed_integer_field_class(32) specific_fc = tc.create_structure_field_class() - specific_fc += [('my_int', my_int_fc)] + specific_fc += [("my_int", my_int_fc)] ec = sc.create_event_class( - name='salut', + name="salut", payload_field_class=payload_fc, specific_context_field_class=specific_fc, ) @@ -159,10 +159,10 @@ class AllMessagesTestCase(unittest.TestCase): self._iter = MyIter def test_all_msg_with_cc(self): - params = {'with_cc': True} - self._src_comp = self._graph.add_component(self._src, 'my_source', params) + params = {"with_cc": True} + self._src_comp = self._graph.add_component(self._src, "my_source", params) self._msg_iter = TestOutputPortMessageIterator( - self._graph, self._src_comp.output_ports['out'] + self._graph, self._src_comp.output_ports["out"] ) for i, msg in enumerate(self._msg_iter): @@ -193,7 +193,7 @@ class AllMessagesTestCase(unittest.TestCase): type(msg.event.payload_field), bt2_field._StructureFieldConst ) self.assertIs( - type(msg.event.payload_field['my_int']), + type(msg.event.payload_field["my_int"]), bt2_field._SignedIntegerFieldConst, ) @@ -267,10 +267,10 @@ class AllMessagesTestCase(unittest.TestCase): raise Exception def test_all_msg_without_cc(self): - params = {'with_cc': False} - self._src_comp = self._graph.add_component(self._src, 'my_source', params) + params = {"with_cc": False} + self._src_comp = self._graph.add_component(self._src, "my_source", params) self._msg_iter = TestOutputPortMessageIterator( - self._graph, self._src_comp.output_ports['out'] + self._graph, self._src_comp.output_ports["out"] ) for i, msg in enumerate(self._msg_iter): @@ -279,7 +279,7 @@ class AllMessagesTestCase(unittest.TestCase): self.assertIs(type(msg.stream), bt2_stream._StreamConst) self.assertEqual(msg.stream.addr, self._stream.addr) with self.assertRaisesRegex( - ValueError, 'stream class has no default clock class' + ValueError, "stream class has no default clock class" ): msg.default_clock_snapshot elif i == 1: @@ -292,7 +292,7 @@ class AllMessagesTestCase(unittest.TestCase): self.assertIs(type(msg.event.cls), bt2_event_class._EventClassConst) self.assertEqual(msg.event.cls.addr, self._event_class.addr) with self.assertRaisesRegex( - ValueError, 'stream class has no default clock class' + ValueError, "stream class has no default clock class" ): msg.default_clock_snapshot elif i == 3: @@ -304,12 +304,12 @@ class AllMessagesTestCase(unittest.TestCase): self.assertIsNone(msg.stream.cls.default_clock_class) with self.assertRaisesRegex( ValueError, - 'such a message has no clock snapshots for this stream class', + "such a message has no clock snapshots for this stream class", ): msg.beginning_default_clock_snapshot with self.assertRaisesRegex( ValueError, - 'such a message has no clock snapshots for this stream class', + "such a message has no clock snapshots for this stream class", ): msg.end_default_clock_snapshot elif i == 4: @@ -328,12 +328,12 @@ class AllMessagesTestCase(unittest.TestCase): self.assertIsNone(msg.stream.cls.default_clock_class) with self.assertRaisesRegex( ValueError, - 'such a message has no clock snapshots for this stream class', + "such a message has no clock snapshots for this stream class", ): msg.beginning_default_clock_snapshot with self.assertRaisesRegex( ValueError, - 'such a message has no clock snapshots for this stream class', + "such a message has no clock snapshots for this stream class", ): msg.end_default_clock_snapshot elif i == 6: @@ -341,18 +341,18 @@ class AllMessagesTestCase(unittest.TestCase): self.assertIs(type(msg.stream), bt2_stream._StreamConst) self.assertEqual(msg.stream.addr, self._stream.addr) with self.assertRaisesRegex( - ValueError, 'stream class has no default clock class' + ValueError, "stream class has no default clock class" ): msg.default_clock_snapshot else: raise Exception def test_msg_stream_with_clock_snapshots(self): - params = {'with_cc': True, 'with_stream_msgs_clock_snapshots': True} + params = {"with_cc": True, "with_stream_msgs_clock_snapshots": True} - self._src_comp = self._graph.add_component(self._src, 'my_source', params) + self._src_comp = self._graph.add_component(self._src, "my_source", params) self._msg_iter = TestOutputPortMessageIterator( - self._graph, self._src_comp.output_ports['out'] + self._graph, self._src_comp.output_ports["out"] ) msgs = list(self._msg_iter) @@ -426,7 +426,7 @@ class CreateDiscardedEventMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded event count is 0', + "discarded event count is 0", ): msg_iter._create_discarded_events_message(stream, count=0) @@ -461,7 +461,7 @@ class CreateDiscardedEventMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( - ValueError, 'stream class does not support discarded events' + ValueError, "stream class does not support discarded events" ): msg_iter._create_discarded_events_message(stream) @@ -479,7 +479,7 @@ class CreateDiscardedEventMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded events have no default clock snapshots for this stream class', + "discarded events have no default clock snapshots for this stream class", ): msg_iter._create_discarded_events_message( stream, beg_clock_snapshot=10, end_clock_snapshot=20 @@ -502,7 +502,7 @@ class CreateDiscardedEventMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded events have default clock snapshots for this stream class', + "discarded events have default clock snapshots for this stream class", ): msg_iter._create_discarded_events_message(stream) @@ -523,7 +523,7 @@ class CreateDiscardedEventMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - r'beginning default clock snapshot value \(20\) is greater than end default clock snapshot value \(10\)', + r"beginning default clock snapshot value \(20\) is greater than end default clock snapshot value \(10\)", ): msg_iter._create_discarded_events_message( stream, beg_clock_snapshot=20, end_clock_snapshot=10 @@ -574,7 +574,7 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded packet count is 0', + "discarded packet count is 0", ): msg_iter._create_discarded_packets_message(stream, count=0) @@ -612,7 +612,7 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( - ValueError, 'stream class does not support discarded packets' + ValueError, "stream class does not support discarded packets" ): msg_iter._create_discarded_packets_message(stream) @@ -632,7 +632,7 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded packets have no default clock snapshots for this stream class', + "discarded packets have no default clock snapshots for this stream class", ): msg_iter._create_discarded_packets_message( stream, beg_clock_snapshot=10, end_clock_snapshot=20 @@ -656,7 +656,7 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - 'discarded packets have default clock snapshots for this stream class', + "discarded packets have default clock snapshots for this stream class", ): msg_iter._create_discarded_packets_message(stream) @@ -678,7 +678,7 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): def msg_iter_next(msg_iter, stream): with self.assertRaisesRegex( ValueError, - r'beginning default clock snapshot value \(20\) is greater than end default clock snapshot value \(10\)', + r"beginning default clock snapshot value \(20\) is greater than end default clock snapshot value \(10\)", ): msg_iter._create_discarded_packets_message( stream, beg_clock_snapshot=20, end_clock_snapshot=10 @@ -690,5 +690,5 @@ class CreateDiscardedPacketMessageTestCase(unittest.TestCase): self.assertEqual(res, 123) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_message_iterator.py b/tests/bindings/python/bt2/test_message_iterator.py index a40283b3..71f63639 100644 --- a/tests/bindings/python/bt2/test_message_iterator.py +++ b/tests/bindings/python/bt2/test_message_iterator.py @@ -16,27 +16,27 @@ class SimpleSink(bt2._UserSinkComponent): # it. def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_consume(self): next(self._msg_iter) def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _create_graph(src_comp_cls, sink_comp_cls, flt_comp_cls=None): graph = bt2.Graph() - src_comp = graph.add_component(src_comp_cls, 'src') - sink_comp = graph.add_component(sink_comp_cls, 'sink') + src_comp = graph.add_component(src_comp_cls, "src") + sink_comp = graph.add_component(sink_comp_cls, "sink") if flt_comp_cls is not None: - flt_comp = graph.add_component(flt_comp_cls, 'flt') - graph.connect_ports(src_comp.output_ports['out'], flt_comp.input_ports['in']) - graph.connect_ports(flt_comp.output_ports['out'], sink_comp.input_ports['in']) + flt_comp = graph.add_component(flt_comp_cls, "flt") + graph.connect_ports(src_comp.output_ports["out"], flt_comp.input_ports["in"]) + graph.connect_ports(flt_comp.output_ports["out"], sink_comp.input_ports["in"]) else: - graph.connect_ports(src_comp.output_ports['out'], sink_comp.input_ports['in']) + graph.connect_ports(src_comp.output_ports["out"], sink_comp.input_ports["in"]) return graph @@ -56,7 +56,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): nonlocal the_output_port_from_source - the_output_port_from_source = self._add_output_port('out', 'user data') + the_output_port_from_source = self._add_output_port("out", "user data") initialized = False graph = _create_graph(MySource, SimpleSink) @@ -65,7 +65,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): self.assertEqual( the_output_port_from_source.addr, the_output_port_from_iter.addr ) - self.assertEqual(the_output_port_from_iter.user_data, 'user data') + self.assertEqual(the_output_port_from_iter.user_data, "user data") def test_create_from_message_iterator(self): class MySourceIter(bt2._UserMessageIterator): @@ -75,14 +75,14 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MySourceIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MyFilterIter(bt2._UserMessageIterator): def __init__(self, config, self_port_output): nonlocal flt_iter_initialized flt_iter_initialized = True self._up_iter = self._create_message_iterator( - self._component._input_ports['in'] + self._component._input_ports["in"] ) def __next__(self): @@ -90,8 +90,8 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(self, config, params, obj): - self._add_input_port('in') - self._add_output_port('out') + self._add_input_port("in") + self._add_output_port("out") src_iter_initialized = False flt_iter_initialized = False @@ -105,10 +105,10 @@ class UserMessageIteratorTestCase(unittest.TestCase): def test_create_from_sink_component_unconnected_port_raises(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._input_port = comp_self._add_input_port('in') + comp_self._input_port = comp_self._add_input_port("in") def _user_graph_is_configured(comp_self): - with self.assertRaisesRegex(ValueError, 'input port is not connected'): + with self.assertRaisesRegex(ValueError, "input port is not connected"): comp_self._create_message_iterator(comp_self._input_port) nonlocal seen @@ -119,7 +119,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): seen = False graph = bt2.Graph() - graph.add_component(MySink, 'snk') + graph.add_component(MySink, "snk") graph.run() self.assertTrue(seen) @@ -128,9 +128,9 @@ class UserMessageIteratorTestCase(unittest.TestCase): def test_create_from_message_iterator_unconnected_port_raises(self): class MyFilterIter(bt2._UserMessageIterator): def __init__(iter_self, config, port): - input_port = iter_self._component._input_ports['in'] + input_port = iter_self._component._input_ports["in"] - with self.assertRaisesRegex(ValueError, 'input port is not connected'): + with self.assertRaisesRegex(ValueError, "input port is not connected"): iter_self._create_message_iterator(input_port) nonlocal seen @@ -138,12 +138,12 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('in') - comp_self._add_output_port('out') + comp_self._add_input_port("in") + comp_self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._input_port = comp_self._add_input_port('in') + comp_self._input_port = comp_self._add_input_port("in") def _user_graph_is_configured(comp_self): comp_self._input_iter = comp_self._create_message_iterator( @@ -155,9 +155,9 @@ class UserMessageIteratorTestCase(unittest.TestCase): seen = False graph = bt2.Graph() - flt = graph.add_component(MyFilter, 'flt') - snk = graph.add_component(MySink, 'snk') - graph.connect_ports(flt.output_ports['out'], snk.input_ports['in']) + flt = graph.add_component(MyFilter, "flt") + snk = graph.add_component(MySink, "snk") + graph.connect_ports(flt.output_ports["out"], snk.input_ports["in"]) graph.run() self.assertTrue(seen) @@ -168,22 +168,22 @@ class UserMessageIteratorTestCase(unittest.TestCase): # are both used in the graph. class MySourceIter(bt2._UserMessageIterator): def __init__(self, config, self_port_output): - raise ValueError('Very bad error') + raise ValueError("Very bad error") class MySource(bt2._UserSourceComponent, message_iterator_class=MySourceIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MyFilterIter(bt2._UserMessageIterator): def __init__(self, config, self_port_output): # This is expected to raise because of the error in # MySourceIter.__init__. - self._create_message_iterator(self._component._input_ports['in']) + self._create_message_iterator(self._component._input_ports["in"]) class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(self, config, params, obj): - self._add_input_port('in') - self._add_output_port('out') + self._add_input_port("in") + self._add_output_port("out") graph = _create_graph(MySource, SimpleSink, MyFilter) @@ -194,9 +194,9 @@ class UserMessageIteratorTestCase(unittest.TestCase): cause = exc[0] self.assertIsInstance(cause, bt2._MessageIteratorErrorCause) - self.assertEqual(cause.component_name, 'src') - self.assertEqual(cause.component_output_port_name, 'out') - self.assertIn('ValueError: Very bad error', cause.message) + self.assertEqual(cause.component_name, "src") + self.assertEqual(cause.component_output_port_name, "out") + self.assertIn("ValueError: Very bad error", cause.message) def test_finalize(self): class MyIter(bt2._UserMessageIterator): @@ -206,7 +206,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") finalized = False graph = _create_graph(MySource, SimpleSink) @@ -222,7 +222,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") config_type = None graph = _create_graph(MySource, SimpleSink) @@ -237,14 +237,14 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal can_seek_forward @@ -268,7 +268,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") graph = _create_graph(MySource, SimpleSink) with self.assertRaises(bt2._Error) as ctx: @@ -285,7 +285,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") self._salut = 23 salut = None @@ -305,7 +305,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") called = False graph = _create_graph(MySource, SimpleSink) @@ -320,7 +320,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") addr = None graph = _create_graph(MySource, SimpleSink) @@ -356,11 +356,11 @@ class UserMessageIteratorTestCase(unittest.TestCase): tc = self._create_trace_class() sc = tc.create_stream_class(supports_packets=True) ec = sc.create_event_class() - self._add_output_port('out', (tc, sc, ec)) + self._add_output_port("out", (tc, sc, ec)) graph = bt2.Graph() - src = graph.add_component(MySource, 'src') - it = TestOutputPortMessageIterator(graph, src.output_ports['out']) + src = graph.add_component(MySource, "src") + it = TestOutputPortMessageIterator(graph, src.output_ports["out"]) # Skip beginning messages. msg = next(it) @@ -385,7 +385,7 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MyFilterIter(bt2._UserMessageIterator): def __init__(self, port): @@ -403,12 +403,12 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(self, config, params, obj): - input_port = self._add_input_port('in') - self._add_output_port('out', input_port) + input_port = self._add_input_port("in") + self._add_output_port("out", input_port) graph = bt2.Graph() - src = graph.add_component(MySource, 'src') - it = TestOutputPortMessageIterator(graph, src.output_ports['out']) + src = graph.add_component(MySource, "src") + it = TestOutputPortMessageIterator(graph, src.output_ports["out"]) # Three times the initial ref count of `None` iterations should # be enough to catch the bug even if there are small differences @@ -431,13 +431,13 @@ class UserMessageIteratorTestCase(unittest.TestCase): class MySource(bt2._UserSourceComponent, message_iterator_class=MySourceIter): def __init__(self, config, params, obj): - self._add_output_port('out') + self._add_output_port("out") class MyFilterIter(bt2._UserMessageIterator): def __init__(self, config, port): # First, create an upstream iterator. self._upstream_iter = self._create_message_iterator( - self._component._input_ports['in'] + self._component._input_ports["in"] ) # Then, voluntarily make a reference cycle that will keep this @@ -446,16 +446,16 @@ class UserMessageIteratorTestCase(unittest.TestCase): self._self = self # Finally, raise an exception to make __init__ fail. - raise ValueError('woops') + raise ValueError("woops") class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(self, config, params, obj): - self._in = self._add_input_port('in') - self._out = self._add_output_port('out') + self._in = self._add_input_port("in") + self._out = self._add_output_port("out") class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") def _user_graph_is_configured(self): self._upstream_iter = self._create_message_iterator(self._input_port) @@ -465,13 +465,13 @@ class UserMessageIteratorTestCase(unittest.TestCase): assert False g = bt2.Graph() - src = g.add_component(MySource, 'src') - flt = g.add_component(MyFilter, 'flt') - snk = g.add_component(MySink, 'snk') - g.connect_ports(src.output_ports['out'], flt.input_ports['in']) - g.connect_ports(flt.output_ports['out'], snk.input_ports['in']) + src = g.add_component(MySource, "src") + flt = g.add_component(MyFilter, "flt") + snk = g.add_component(MySink, "snk") + g.connect_ports(src.output_ports["out"], flt.input_ports["in"]) + g.connect_ports(flt.output_ports["out"], snk.input_ports["in"]) - with self.assertRaisesRegex(bt2._Error, 'ValueError: woops'): + with self.assertRaisesRegex(bt2._Error, "ValueError: woops"): g.run() @@ -527,12 +527,12 @@ def _setup_seek_test( sc = tc.create_stream_class(supports_packets=True) ec = sc.create_event_class() - self._add_output_port('out', (tc, sc, ec)) + self._add_output_port("out", (tc, sc, ec)) class MyFilterIter(bt2._UserMessageIterator): def __init__(self, config, port): self._upstream_iter = self._create_message_iterator( - self._component._input_ports['in'] + self._component._input_ports["in"] ) config.can_seek_forward = self._upstream_iter.can_seek_forward @@ -553,8 +553,8 @@ def _setup_seek_test( class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter): def __init__(self, config, params, obj): - self._add_input_port('in') - self._add_output_port('out') + self._add_input_port("in") + self._add_output_port("out") return _create_graph(MySource, sink_cls, flt_comp_cls=MyFilter) @@ -570,10 +570,10 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): def test_can_seek_beginning(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal can_seek_beginning @@ -604,10 +604,10 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): # a _user_seek_beginning method. class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal can_seek_beginning @@ -626,10 +626,10 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): # a _user_seek_beginning method. class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal can_seek_beginning @@ -643,17 +643,17 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): def test_can_seek_beginning_user_error(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): # This is expected to raise. self._msg_iter.can_seek_beginning() def _user_can_seek_beginning(self): - raise ValueError('moustiquaire') + raise ValueError("moustiquaire") graph = _setup_seek_test( MySink, @@ -665,22 +665,22 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): graph.run_once() cause = ctx.exception[0] - self.assertIn('ValueError: moustiquaire', cause.message) + self.assertIn("ValueError: moustiquaire", cause.message) def test_can_seek_beginning_wrong_return_value(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): # This is expected to raise. self._msg_iter.can_seek_beginning() def _user_can_seek_beginning(self): - return 'Amqui' + return "Amqui" graph = _setup_seek_test( MySink, @@ -697,10 +697,10 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): def test_seek_beginning(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal do_seek_beginning @@ -739,16 +739,16 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): def test_seek_beginning_user_error(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): self._msg_iter.seek_beginning() def _user_seek_beginning(self): - raise ValueError('ouch') + raise ValueError("ouch") graph = _setup_seek_test(MySink, user_seek_beginning=_user_seek_beginning) @@ -980,10 +980,10 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase): ): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): nonlocal can_seek_ns_from_origin @@ -1037,17 +1037,17 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase): def test_can_seek_ns_from_origin_user_error(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): # This is expected to raise. self._msg_iter.can_seek_ns_from_origin(2) def _user_can_seek_ns_from_origin(self, ns_from_origin): - raise ValueError('Joutel') + raise ValueError("Joutel") graph = _setup_seek_test( MySink, @@ -1059,22 +1059,22 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase): graph.run_once() cause = ctx.exception[0] - self.assertIn('ValueError: Joutel', cause.message) + self.assertIn("ValueError: Joutel", cause.message) def test_can_seek_ns_from_origin_wrong_return_value(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): # This is expected to raise. self._msg_iter.can_seek_ns_from_origin(2) def _user_can_seek_ns_from_origin(self, ns_from_origin): - return 'Nitchequon' + return "Nitchequon" graph = _setup_seek_test( MySink, @@ -1091,10 +1091,10 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase): def test_seek_ns_from_origin(self): class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): self._msg_iter.seek_ns_from_origin(17) @@ -1112,5 +1112,5 @@ class UserMessageIteratorSeekNsFromOriginTestCase(unittest.TestCase): self.assertEqual(actual_ns_from_origin, 17) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_mip.py b/tests/bindings/python/bt2/test_mip.py index 87297599..a73054fa 100644 --- a/tests/bindings/python/bt2/test_mip.py +++ b/tests/bindings/python/bt2/test_mip.py @@ -85,7 +85,7 @@ class MipTestCase(unittest.TestCase): descriptors = [bt2.ComponentDescriptor(Source1)] with self.assertRaises(TypeError): - bt2.get_greatest_operative_mip_version(descriptors, 'lel') + bt2.get_greatest_operative_mip_version(descriptors, "lel") def test_get_greatest_operative_mip_version_wrong_log_level_value(self): class Source1( @@ -102,5 +102,5 @@ class MipTestCase(unittest.TestCase): self.assertEqual(bt2.get_maximal_mip_version(), 0) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_package.py b/tests/bindings/python/bt2/test_package.py index df67b7fd..f13f8eb0 100644 --- a/tests/bindings/python/bt2/test_package.py +++ b/tests/bindings/python/bt2/test_package.py @@ -13,177 +13,177 @@ class PackageTestCase(unittest.TestCase): _public_names = [ - '__version__', - '_ArrayField', - '_ArrayFieldClass', - '_ArrayFieldClassConst', - '_ArrayFieldConst', - '_ArrayValueConst', - '_BitArrayField', - '_BitArrayFieldClass', - '_BitArrayFieldClassConst', - '_BitArrayFieldConst', - '_BoolField', - '_BoolFieldClass', - '_BoolFieldClassConst', - '_BoolFieldConst', - '_BoolValueConst', - '_ClockSnapshotConst', - '_ComponentClassErrorCause', - '_ComponentErrorCause', - '_CurrentArrayElementFieldPathItem', - '_CurrentOptionContentFieldPathItem', - '_DiscardedEventsMessage', - '_DiscardedEventsMessageConst', - '_DiscardedPacketsMessage', - '_DiscardedPacketsMessageConst', - '_DoublePrecisionRealField', - '_DoublePrecisionRealFieldConst', - '_DynamicArrayField', - '_DynamicArrayFieldClass', - '_DynamicArrayFieldClassConst', - '_DynamicArrayFieldConst', - '_DynamicArrayWithLengthFieldFieldClass', - '_DynamicArrayWithLengthFieldFieldClassConst', - '_EnumerationField', - '_EnumerationFieldClass', - '_EnumerationFieldClassConst', - '_EnumerationFieldConst', - '_Error', - '_ErrorCause', - '_EventMessage', - '_EventMessageConst', - '_FilterComponentClassConst', - '_FilterComponentConst', - '_IndexFieldPathItem', - '_IntegerField', - '_IntegerFieldClass', - '_IntegerFieldClassConst', - '_IntegerFieldConst', - '_IntegerValue', - '_IntegerValueConst', - '_MapValueConst', - '_MessageIteratorErrorCause', - '_MessageIteratorInactivityMessage', - '_MessageIteratorInactivityMessageConst', - '_OptionFieldClass', - '_OptionFieldClassConst', - '_OptionWithBoolSelectorFieldClass', - '_OptionWithBoolSelectorFieldClassConst', - '_OptionWithIntegerSelectorFieldClass', - '_OptionWithIntegerSelectorFieldClassConst', - '_OptionWithSelectorFieldClass', - '_OptionWithSelectorFieldClassConst', - '_OptionWithSignedIntegerSelectorFieldClass', - '_OptionWithSignedIntegerSelectorFieldClassConst', - '_OptionWithUnsignedIntegerSelectorFieldClass', - '_OptionWithUnsignedIntegerSelectorFieldClassConst', - '_PacketBeginningMessage', - '_PacketBeginningMessageConst', - '_PacketEndMessage', - '_PacketEndMessageConst', - '_RealField', - '_RealFieldClass', - '_RealFieldClassConst', - '_RealFieldConst', - '_RealValueConst', - '_SignedEnumerationField', - '_SignedEnumerationFieldClass', - '_SignedEnumerationFieldClassConst', - '_SignedEnumerationFieldConst', - '_SignedIntegerField', - '_SignedIntegerFieldClass', - '_SignedIntegerFieldClassConst', - '_SignedIntegerFieldConst', - '_SignedIntegerRangeConst', - '_SignedIntegerRangeSetConst', - '_SignedIntegerValueConst', - '_SinglePrecisionRealField', - '_SinglePrecisionRealFieldConst', - '_SinkComponentClassConst', - '_SinkComponentConst', - '_SourceComponentClassConst', - '_SourceComponentConst', - '_StaticArrayField', - '_StaticArrayFieldClass', - '_StaticArrayFieldClassConst', - '_StaticArrayFieldConst', - '_StreamBeginningMessage', - '_StreamBeginningMessageConst', - '_StreamEndMessage', - '_StreamEndMessageConst', - '_StringField', - '_StringFieldClass', - '_StringFieldClassConst', - '_StringFieldConst', - '_StringValueConst', - '_StructureField', - '_StructureFieldClass', - '_StructureFieldClassConst', - '_StructureFieldConst', - '_UnknownClockSnapshot', - '_UnsignedEnumerationField', - '_UnsignedEnumerationFieldClass', - '_UnsignedEnumerationFieldClassConst', - '_UnsignedEnumerationFieldConst', - '_UnsignedIntegerField', - '_UnsignedIntegerFieldClass', - '_UnsignedIntegerFieldClassConst', - '_UnsignedIntegerFieldConst', - '_UnsignedIntegerRangeConst', - '_UnsignedIntegerRangeSetConst', - '_UnsignedIntegerValueConst', - '_UserFilterComponent', - '_UserMessageIterator', - '_UserSinkComponent', - '_UserSourceComponent', - '_VariantField', - '_VariantField', - '_VariantFieldClass', - '_VariantFieldClassConst', - '_VariantFieldClassWithIntegerSelector', - '_VariantFieldClassWithIntegerSelectorConst', - '_VariantFieldClassWithoutSelector', - '_VariantFieldClassWithoutSelectorConst', - '_VariantFieldClassWithSignedIntegerSelector', - '_VariantFieldClassWithSignedIntegerSelectorConst', - '_VariantFieldClassWithUnsignedIntegerSelector', - '_VariantFieldClassWithUnsignedIntegerSelectorConst', - '_VariantFieldConst', - '_VariantFieldConst', - 'ArrayValue', - 'AutoSourceComponentSpec', - 'BoolValue', - 'ClockClassOffset', - 'ComponentClassType', - 'ComponentDescriptor', - 'ComponentSpec', - 'create_value', - 'EventClassLogLevel', - 'FieldPathScope', - 'find_plugin', - 'find_plugins', - 'find_plugins_in_path', - 'get_global_logging_level', - 'get_minimal_logging_level', - 'Graph', - 'IntegerDisplayBase', - 'Interrupter', - 'LoggingLevel', - 'MapValue', - 'plugin_component_class', - 'QueryExecutor', - 'RealValue', - 'register_plugin', - 'set_global_logging_level', - 'SignedIntegerRange', - 'SignedIntegerRangeSet', - 'SignedIntegerValue', - 'StringValue', - 'TraceCollectionMessageIterator', - 'UnsignedIntegerRange', - 'UnsignedIntegerRangeSet', - 'UnsignedIntegerValue', + "__version__", + "_ArrayField", + "_ArrayFieldClass", + "_ArrayFieldClassConst", + "_ArrayFieldConst", + "_ArrayValueConst", + "_BitArrayField", + "_BitArrayFieldClass", + "_BitArrayFieldClassConst", + "_BitArrayFieldConst", + "_BoolField", + "_BoolFieldClass", + "_BoolFieldClassConst", + "_BoolFieldConst", + "_BoolValueConst", + "_ClockSnapshotConst", + "_ComponentClassErrorCause", + "_ComponentErrorCause", + "_CurrentArrayElementFieldPathItem", + "_CurrentOptionContentFieldPathItem", + "_DiscardedEventsMessage", + "_DiscardedEventsMessageConst", + "_DiscardedPacketsMessage", + "_DiscardedPacketsMessageConst", + "_DoublePrecisionRealField", + "_DoublePrecisionRealFieldConst", + "_DynamicArrayField", + "_DynamicArrayFieldClass", + "_DynamicArrayFieldClassConst", + "_DynamicArrayFieldConst", + "_DynamicArrayWithLengthFieldFieldClass", + "_DynamicArrayWithLengthFieldFieldClassConst", + "_EnumerationField", + "_EnumerationFieldClass", + "_EnumerationFieldClassConst", + "_EnumerationFieldConst", + "_Error", + "_ErrorCause", + "_EventMessage", + "_EventMessageConst", + "_FilterComponentClassConst", + "_FilterComponentConst", + "_IndexFieldPathItem", + "_IntegerField", + "_IntegerFieldClass", + "_IntegerFieldClassConst", + "_IntegerFieldConst", + "_IntegerValue", + "_IntegerValueConst", + "_MapValueConst", + "_MessageIteratorErrorCause", + "_MessageIteratorInactivityMessage", + "_MessageIteratorInactivityMessageConst", + "_OptionFieldClass", + "_OptionFieldClassConst", + "_OptionWithBoolSelectorFieldClass", + "_OptionWithBoolSelectorFieldClassConst", + "_OptionWithIntegerSelectorFieldClass", + "_OptionWithIntegerSelectorFieldClassConst", + "_OptionWithSelectorFieldClass", + "_OptionWithSelectorFieldClassConst", + "_OptionWithSignedIntegerSelectorFieldClass", + "_OptionWithSignedIntegerSelectorFieldClassConst", + "_OptionWithUnsignedIntegerSelectorFieldClass", + "_OptionWithUnsignedIntegerSelectorFieldClassConst", + "_PacketBeginningMessage", + "_PacketBeginningMessageConst", + "_PacketEndMessage", + "_PacketEndMessageConst", + "_RealField", + "_RealFieldClass", + "_RealFieldClassConst", + "_RealFieldConst", + "_RealValueConst", + "_SignedEnumerationField", + "_SignedEnumerationFieldClass", + "_SignedEnumerationFieldClassConst", + "_SignedEnumerationFieldConst", + "_SignedIntegerField", + "_SignedIntegerFieldClass", + "_SignedIntegerFieldClassConst", + "_SignedIntegerFieldConst", + "_SignedIntegerRangeConst", + "_SignedIntegerRangeSetConst", + "_SignedIntegerValueConst", + "_SinglePrecisionRealField", + "_SinglePrecisionRealFieldConst", + "_SinkComponentClassConst", + "_SinkComponentConst", + "_SourceComponentClassConst", + "_SourceComponentConst", + "_StaticArrayField", + "_StaticArrayFieldClass", + "_StaticArrayFieldClassConst", + "_StaticArrayFieldConst", + "_StreamBeginningMessage", + "_StreamBeginningMessageConst", + "_StreamEndMessage", + "_StreamEndMessageConst", + "_StringField", + "_StringFieldClass", + "_StringFieldClassConst", + "_StringFieldConst", + "_StringValueConst", + "_StructureField", + "_StructureFieldClass", + "_StructureFieldClassConst", + "_StructureFieldConst", + "_UnknownClockSnapshot", + "_UnsignedEnumerationField", + "_UnsignedEnumerationFieldClass", + "_UnsignedEnumerationFieldClassConst", + "_UnsignedEnumerationFieldConst", + "_UnsignedIntegerField", + "_UnsignedIntegerFieldClass", + "_UnsignedIntegerFieldClassConst", + "_UnsignedIntegerFieldConst", + "_UnsignedIntegerRangeConst", + "_UnsignedIntegerRangeSetConst", + "_UnsignedIntegerValueConst", + "_UserFilterComponent", + "_UserMessageIterator", + "_UserSinkComponent", + "_UserSourceComponent", + "_VariantField", + "_VariantField", + "_VariantFieldClass", + "_VariantFieldClassConst", + "_VariantFieldClassWithIntegerSelector", + "_VariantFieldClassWithIntegerSelectorConst", + "_VariantFieldClassWithoutSelector", + "_VariantFieldClassWithoutSelectorConst", + "_VariantFieldClassWithSignedIntegerSelector", + "_VariantFieldClassWithSignedIntegerSelectorConst", + "_VariantFieldClassWithUnsignedIntegerSelector", + "_VariantFieldClassWithUnsignedIntegerSelectorConst", + "_VariantFieldConst", + "_VariantFieldConst", + "ArrayValue", + "AutoSourceComponentSpec", + "BoolValue", + "ClockClassOffset", + "ComponentClassType", + "ComponentDescriptor", + "ComponentSpec", + "create_value", + "EventClassLogLevel", + "FieldPathScope", + "find_plugin", + "find_plugins", + "find_plugins_in_path", + "get_global_logging_level", + "get_minimal_logging_level", + "Graph", + "IntegerDisplayBase", + "Interrupter", + "LoggingLevel", + "MapValue", + "plugin_component_class", + "QueryExecutor", + "RealValue", + "register_plugin", + "set_global_logging_level", + "SignedIntegerRange", + "SignedIntegerRangeSet", + "SignedIntegerValue", + "StringValue", + "TraceCollectionMessageIterator", + "UnsignedIntegerRange", + "UnsignedIntegerRangeSet", + "UnsignedIntegerValue", ] for name in _public_names: @@ -191,8 +191,8 @@ for name in _public_names: def test_func(self): self._assert_in_bt2(name) - setattr(PackageTestCase, 'test_has_' + name, test_func) + setattr(PackageTestCase, "test_has_" + name, test_func) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_packet.py b/tests/bindings/python/bt2/test_packet.py index 3151c8a2..5448c03c 100644 --- a/tests/bindings/python/bt2/test_packet.py +++ b/tests/bindings/python/bt2/test_packet.py @@ -14,7 +14,7 @@ class PacketTestCase(unittest.TestCase): @staticmethod def _create_packet(with_pc): def create_tc_cc(comp_self): - cc = comp_self._create_clock_class(frequency=1000, name='my_cc') + cc = comp_self._create_clock_class(frequency=1000, name="my_cc") tc = comp_self._create_trace_class() return cc, tc @@ -23,8 +23,8 @@ class PacketTestCase(unittest.TestCase): # stream event context sec = tc.create_structure_field_class() sec += [ - ('cpu_id', tc.create_signed_integer_field_class(8)), - ('stuff', tc.create_double_precision_real_field_class()), + ("cpu_id", tc.create_signed_integer_field_class(8)), + ("stuff", tc.create_double_precision_real_field_class()), ] # packet context @@ -32,10 +32,10 @@ class PacketTestCase(unittest.TestCase): if with_pc: pc = tc.create_structure_field_class() pc += [ - ('something', tc.create_signed_integer_field_class(8)), - ('something_else', tc.create_double_precision_real_field_class()), - ('events_discarded', tc.create_unsigned_integer_field_class(64)), - ('packet_seq_num', tc.create_unsigned_integer_field_class(64)), + ("something", tc.create_signed_integer_field_class(8)), + ("something_else", tc.create_double_precision_real_field_class()), + ("events_discarded", tc.create_unsigned_integer_field_class(64)), + ("packet_seq_num", tc.create_unsigned_integer_field_class(64)), ] # stream class @@ -49,20 +49,20 @@ class PacketTestCase(unittest.TestCase): # event context ec = tc.create_structure_field_class() ec += [ - ('ant', tc.create_signed_integer_field_class(16)), - ('msg', tc.create_string_field_class()), + ("ant", tc.create_signed_integer_field_class(16)), + ("msg", tc.create_string_field_class()), ] # event payload ep = tc.create_structure_field_class() ep += [ - ('giraffe', tc.create_signed_integer_field_class(32)), - ('gnu', tc.create_signed_integer_field_class(8)), - ('mosquito', tc.create_signed_integer_field_class(8)), + ("giraffe", tc.create_signed_integer_field_class(32)), + ("gnu", tc.create_signed_integer_field_class(8)), + ("mosquito", tc.create_signed_integer_field_class(8)), ] # event class - event_class = sc.create_event_class(name='ec', payload_field_class=ep) + event_class = sc.create_event_class(name="ec", payload_field_class=ep) event_class.common_context_field_class = ec # trace @@ -97,5 +97,5 @@ class PacketTestCase(unittest.TestCase): self.assertIsNone(packet.context_field) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_plugin.py b/tests/bindings/python/bt2/test_plugin.py index 4abf8846..7c766c69 100644 --- a/tests/bindings/python/bt2/test_plugin.py +++ b/tests/bindings/python/bt2/test_plugin.py @@ -8,8 +8,8 @@ import bt2 import os -_TEST_PLUGIN_PLUGINS_PATH = os.environ['BT_PLUGINS_PATH'] -_TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS = {'cygwin': 'dll', 'mingw': 'dll'} +_TEST_PLUGIN_PLUGINS_PATH = os.environ["BT_PLUGINS_PATH"] +_TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS = {"cygwin": "dll", "mingw": "dll"} class PluginSetTestCase(unittest.TestCase): @@ -28,16 +28,16 @@ class PluginSetTestCase(unittest.TestCase): for plugin in pset: names.add(plugin.name) - self.assertTrue('ctf' in names) - self.assertTrue('utils' in names) - self.assertTrue('text' in names) + self.assertTrue("ctf" in names) + self.assertTrue("utils" in names) + self.assertTrue("text" in names) class FindPluginsTestCase(unittest.TestCase): def test_find_nonexistent_dir(self): with self.assertRaises(ValueError): bt2.find_plugins_in_path( - '/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41' + "/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41" ) def test_find_none_existing_dir(self): @@ -50,10 +50,10 @@ class FindPluginsTestCase(unittest.TestCase): def test_find_file(self): extension = _TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS.get( - os.environ['BT_TESTS_OS_TYPE'], 'so' + os.environ["BT_TESTS_OS_TYPE"], "so" ) - plugin_name = 'babeltrace-plugin-utils.{}'.format(extension) - path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, 'utils', '.libs', plugin_name) + plugin_name = "babeltrace-plugin-utils.{}".format(extension) + path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, "utils", ".libs", plugin_name) pset = bt2.find_plugins_in_path(path) self.assertTrue(len(pset) == 1) @@ -61,26 +61,26 @@ class FindPluginsTestCase(unittest.TestCase): class FindPluginTestCase(unittest.TestCase): def test_find_none(self): plugin = bt2.find_plugin( - 'this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41' + "this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41" ) self.assertIsNone(plugin) def test_find_existing(self): - plugin = bt2.find_plugin('ctf', find_in_user_dir=False, find_in_sys_dir=False) + plugin = bt2.find_plugin("ctf", find_in_user_dir=False, find_in_sys_dir=False) self.assertIsNotNone(plugin) class PluginTestCase(unittest.TestCase): def setUp(self): self._plugin = bt2.find_plugin( - 'ctf', find_in_user_dir=False, find_in_sys_dir=False + "ctf", find_in_user_dir=False, find_in_sys_dir=False ) def tearDown(self): del self._plugin def test_name(self): - self.assertEqual(self._plugin.name, 'ctf') + self.assertEqual(self._plugin.name, "ctf") def test_path(self): plugin_path = os.path.abspath(os.path.normcase(self._plugin.path)) @@ -88,13 +88,13 @@ class PluginTestCase(unittest.TestCase): self.assertTrue(plugin_path.startswith(plugin_path_env)) def test_author(self): - self.assertEqual(self._plugin.author, 'EfficiOS ') + self.assertEqual(self._plugin.author, "EfficiOS ") def test_license(self): - self.assertEqual(self._plugin.license, 'MIT') + self.assertEqual(self._plugin.license, "MIT") def test_description(self): - self.assertEqual(self._plugin.description, 'CTF input and output') + self.assertEqual(self._plugin.description, "CTF input and output") def test_version(self): self.assertIsNone(self._plugin.version) @@ -103,11 +103,11 @@ class PluginTestCase(unittest.TestCase): self.assertEqual(len(self._plugin.source_component_classes), 2) def test_source_comp_classes_getitem(self): - self.assertEqual(self._plugin.source_component_classes['fs'].name, 'fs') + self.assertEqual(self._plugin.source_component_classes["fs"].name, "fs") def test_source_comp_classes_getitem_invalid(self): with self.assertRaises(KeyError): - self._plugin.source_component_classes['lol'] + self._plugin.source_component_classes["lol"] def test_source_comp_classes_iter(self): plugins = {} @@ -115,18 +115,18 @@ class PluginTestCase(unittest.TestCase): for cc_name, cc in self._plugin.source_component_classes.items(): plugins[cc_name] = cc - self.assertTrue('fs' in plugins) - self.assertTrue('lttng-live' in plugins) - self.assertEqual(plugins['fs'].name, 'fs') - self.assertEqual(plugins['lttng-live'].name, 'lttng-live') + self.assertTrue("fs" in plugins) + self.assertTrue("lttng-live" in plugins) + self.assertEqual(plugins["fs"].name, "fs") + self.assertEqual(plugins["lttng-live"].name, "lttng-live") def test_filter_comp_classes_len(self): - plugin = bt2.find_plugin('utils', find_in_user_dir=False, find_in_sys_dir=False) + plugin = bt2.find_plugin("utils", find_in_user_dir=False, find_in_sys_dir=False) self.assertEqual(len(plugin.filter_component_classes), 2) def test_sink_comp_classes_len(self): self.assertEqual(len(self._plugin.sink_component_classes), 1) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_port.py b/tests/bindings/python/bt2/test_port.py index e6db06ea..17945cb0 100644 --- a/tests/bindings/python/bt2/test_port.py +++ b/tests/bindings/python/bt2/test_port.py @@ -14,7 +14,7 @@ class PortTestCase(unittest.TestCase): graph = bt2.Graph() if name is None: - name = 'comp' + name = "comp" return graph.add_component(comp_cls, name) @@ -23,12 +23,12 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port = comp_self._add_output_port('out') - self.assertEqual(port.name, 'out') + port = comp_self._add_output_port("out") + self.assertEqual(port.name, "out") comp = self._create_comp(MySource) self.assertEqual(len(comp.output_ports), 1) - self.assertIs(type(comp.output_ports['out']), bt2_port._OutputPortConst) + self.assertIs(type(comp.output_ports["out"]), bt2_port._OutputPortConst) # Test adding output port with duplicate name to source. def test_src_add_output_port_dup_name_raises(self): @@ -36,13 +36,13 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('out') + comp_self._add_output_port("out") with self.assertRaisesRegex( ValueError, "source component `comp` already contains an output port named `out`", ): - comp_self._add_output_port('out') + comp_self._add_output_port("out") nonlocal seen seen = True @@ -56,8 +56,8 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port = comp_self._add_output_port('out') - self.assertEqual(port.name, 'out') + port = comp_self._add_output_port("out") + self.assertEqual(port.name, "out") comp = self._create_comp(MyFilter) self.assertEqual(len(comp.output_ports), 1) @@ -68,13 +68,13 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('out') + comp_self._add_output_port("out") with self.assertRaisesRegex( ValueError, "filter component `comp` already contains an output port named `out`", ): - comp_self._add_output_port('out') + comp_self._add_output_port("out") nonlocal seen seen = True @@ -88,12 +88,12 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port = comp_self._add_input_port('in') - self.assertEqual(port.name, 'in') + port = comp_self._add_input_port("in") + self.assertEqual(port.name, "in") comp = self._create_comp(MyFilter) self.assertEqual(len(comp.input_ports), 1) - self.assertIs(type(comp.input_ports['in']), bt2_port._InputPortConst) + self.assertIs(type(comp.input_ports["in"]), bt2_port._InputPortConst) # Test adding input port with duplicate name to filter. def test_flt_add_input_port_dup_name_raises(self): @@ -101,13 +101,13 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('in') + comp_self._add_input_port("in") with self.assertRaisesRegex( ValueError, "filter component `comp` already contains an input port named `in`", ): - comp_self._add_input_port('in') + comp_self._add_input_port("in") nonlocal seen seen = True @@ -119,8 +119,8 @@ class PortTestCase(unittest.TestCase): def test_sink_add_input_port(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port = comp_self._add_input_port('in') - self.assertEqual(port.name, 'in') + port = comp_self._add_input_port("in") + self.assertEqual(port.name, "in") def _user_consume(self): pass @@ -132,13 +132,13 @@ class PortTestCase(unittest.TestCase): def test_sink_add_input_port_dup_name_raises(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('in') + comp_self._add_input_port("in") with self.assertRaisesRegex( ValueError, "sink component `comp` already contains an input port named `in`", ): - comp_self._add_input_port('in') + comp_self._add_input_port("in") nonlocal seen seen = True @@ -155,12 +155,12 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') - self.assertEqual(port3.addr, comp_self._output_ports['insert'].addr) - self.assertEqual(port2.addr, comp_self._output_ports['print'].addr) - self.assertEqual(port1.addr, comp_self._output_ports['clear'].addr) + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") + self.assertEqual(port3.addr, comp_self._output_ports["insert"].addr) + self.assertEqual(port2.addr, comp_self._output_ports["print"].addr) + self.assertEqual(port1.addr, comp_self._output_ports["clear"].addr) self._create_comp(MySource) @@ -169,12 +169,12 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') - self.assertEqual(port3.addr, comp_self._output_ports['insert'].addr) - self.assertEqual(port2.addr, comp_self._output_ports['print'].addr) - self.assertEqual(port1.addr, comp_self._output_ports['clear'].addr) + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") + self.assertEqual(port3.addr, comp_self._output_ports["insert"].addr) + self.assertEqual(port2.addr, comp_self._output_ports["print"].addr) + self.assertEqual(port1.addr, comp_self._output_ports["clear"].addr) self._create_comp(MyFilter) @@ -183,24 +183,24 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') - self.assertEqual(port3.addr, comp_self._input_ports['insert'].addr) - self.assertEqual(port2.addr, comp_self._input_ports['print'].addr) - self.assertEqual(port1.addr, comp_self._input_ports['clear'].addr) + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") + self.assertEqual(port3.addr, comp_self._input_ports["insert"].addr) + self.assertEqual(port2.addr, comp_self._input_ports["print"].addr) + self.assertEqual(port1.addr, comp_self._input_ports["clear"].addr) self._create_comp(MyFilter) def test_user_sink_input_ports_getitem(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') - self.assertEqual(port3.addr, comp_self._input_ports['insert'].addr) - self.assertEqual(port2.addr, comp_self._input_ports['print'].addr) - self.assertEqual(port1.addr, comp_self._input_ports['clear'].addr) + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") + self.assertEqual(port3.addr, comp_self._input_ports["insert"].addr) + self.assertEqual(port2.addr, comp_self._input_ports["print"].addr) + self.assertEqual(port1.addr, comp_self._input_ports["clear"].addr) def _user_consume(self): pass @@ -212,12 +212,12 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") with self.assertRaises(KeyError): - comp_self._output_ports['hello'] + comp_self._output_ports["hello"] self._create_comp(MySource) @@ -226,12 +226,12 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") with self.assertRaises(KeyError): - comp_self._output_ports['hello'] + comp_self._output_ports["hello"] self._create_comp(MyFilter) @@ -240,24 +240,24 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") with self.assertRaises(KeyError): - comp_self._input_ports['hello'] + comp_self._input_ports["hello"] self._create_comp(MyFilter) def test_user_sink_input_ports_getitem_invalid_key(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") with self.assertRaises(KeyError): - comp_self._input_ports['hello'] + comp_self._input_ports["hello"] def _user_consume(self): pass @@ -269,9 +269,9 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") self.assertEqual(len(comp_self._output_ports), 3) self._create_comp(MySource) @@ -281,9 +281,9 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") self.assertEqual(len(comp_self._output_ports), 3) self._create_comp(MyFilter) @@ -293,9 +293,9 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") self.assertEqual(len(comp_self._input_ports), 3) self._create_comp(MyFilter) @@ -303,9 +303,9 @@ class PortTestCase(unittest.TestCase): def test_user_sink_input_ports_len(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") self.assertEqual(len(comp_self._input_ports), 3) def _user_consume(self): @@ -318,19 +318,19 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") ports = [] for port_name, port in comp_self._output_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) self._create_comp(MySource) @@ -340,19 +340,19 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") ports = [] for port_name, port in comp_self._output_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) self._create_comp(MyFilter) @@ -362,19 +362,19 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") ports = [] for port_name, port in comp_self._input_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) self._create_comp(MyFilter) @@ -382,19 +382,19 @@ class PortTestCase(unittest.TestCase): def test_user_sink_input_ports_iter(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") ports = [] for port_name, port in comp_self._input_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) def _user_consume(self): @@ -412,14 +412,14 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") comp = self._create_comp(MySource) - self.assertEqual(port3.addr, comp.output_ports['insert'].addr) - self.assertEqual(port2.addr, comp.output_ports['print'].addr) - self.assertEqual(port1.addr, comp.output_ports['clear'].addr) + self.assertEqual(port3.addr, comp.output_ports["insert"].addr) + self.assertEqual(port2.addr, comp.output_ports["print"].addr) + self.assertEqual(port1.addr, comp.output_ports["clear"].addr) del port1 del port2 del port3 @@ -434,14 +434,14 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") comp = self._create_comp(MyFilter) - self.assertEqual(port3.addr, comp.output_ports['insert'].addr) - self.assertEqual(port2.addr, comp.output_ports['print'].addr) - self.assertEqual(port1.addr, comp.output_ports['clear'].addr) + self.assertEqual(port3.addr, comp.output_ports["insert"].addr) + self.assertEqual(port2.addr, comp.output_ports["print"].addr) + self.assertEqual(port1.addr, comp.output_ports["clear"].addr) del port1 del port2 del port3 @@ -456,14 +456,14 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") comp = self._create_comp(MyFilter) - self.assertEqual(port3.addr, comp.input_ports['insert'].addr) - self.assertEqual(port2.addr, comp.input_ports['print'].addr) - self.assertEqual(port1.addr, comp.input_ports['clear'].addr) + self.assertEqual(port3.addr, comp.input_ports["insert"].addr) + self.assertEqual(port2.addr, comp.input_ports["print"].addr) + self.assertEqual(port1.addr, comp.input_ports["clear"].addr) del port1 del port2 del port3 @@ -476,17 +476,17 @@ class PortTestCase(unittest.TestCase): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") def _user_consume(self): pass comp = self._create_comp(MySink) - self.assertEqual(port3.addr, comp.input_ports['insert'].addr) - self.assertEqual(port2.addr, comp.input_ports['print'].addr) - self.assertEqual(port1.addr, comp.input_ports['clear'].addr) + self.assertEqual(port3.addr, comp.input_ports["insert"].addr) + self.assertEqual(port2.addr, comp.input_ports["print"].addr) + self.assertEqual(port1.addr, comp.input_ports["clear"].addr) del port1 del port2 del port3 @@ -496,52 +496,52 @@ class PortTestCase(unittest.TestCase): bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") comp = self._create_comp(MySource) with self.assertRaises(KeyError): - comp.output_ports['hello'] + comp.output_ports["hello"] def test_gen_flt_output_ports_getitem_invalid_key(self): class MyFilter( bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") comp = self._create_comp(MyFilter) with self.assertRaises(KeyError): - comp.output_ports['hello'] + comp.output_ports["hello"] def test_gen_flt_input_ports_getitem_invalid_key(self): class MyFilter( bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") comp = self._create_comp(MyFilter) with self.assertRaises(KeyError): - comp.input_ports['hello'] + comp.input_ports["hello"] def test_gen_sink_input_ports_getitem_invalid_key(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") with self.assertRaises(KeyError): - comp_self._input_ports['hello'] + comp_self._input_ports["hello"] def _user_consume(self): pass @@ -549,16 +549,16 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySink) with self.assertRaises(KeyError): - comp.input_ports['hello'] + comp.input_ports["hello"] def test_gen_src_output_ports_len(self): class MySource( bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") comp = self._create_comp(MySource) self.assertEqual(len(comp.output_ports), 3) @@ -568,9 +568,9 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_output_port('clear') - comp_self._add_output_port('print') - comp_self._add_output_port('insert') + comp_self._add_output_port("clear") + comp_self._add_output_port("print") + comp_self._add_output_port("insert") comp = self._create_comp(MyFilter) self.assertEqual(len(comp.output_ports), 3) @@ -580,9 +580,9 @@ class PortTestCase(unittest.TestCase): bt2._UserFilterComponent, message_iterator_class=bt2._UserMessageIterator ): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") comp = self._create_comp(MyFilter) self.assertEqual(len(comp.input_ports), 3) @@ -590,9 +590,9 @@ class PortTestCase(unittest.TestCase): def test_gen_sink_input_ports_len(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') - comp_self._add_input_port('print') - comp_self._add_input_port('insert') + comp_self._add_input_port("clear") + comp_self._add_input_port("print") + comp_self._add_input_port("insert") def _user_consume(self): pass @@ -610,9 +610,9 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") comp = self._create_comp(MySource) ports = [] @@ -620,11 +620,11 @@ class PortTestCase(unittest.TestCase): for port_name, port in comp.output_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) del port1 del port2 @@ -640,9 +640,9 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_output_port('clear') - port2 = comp_self._add_output_port('print') - port3 = comp_self._add_output_port('insert') + port1 = comp_self._add_output_port("clear") + port2 = comp_self._add_output_port("print") + port3 = comp_self._add_output_port("insert") comp = self._create_comp(MyFilter) ports = [] @@ -650,11 +650,11 @@ class PortTestCase(unittest.TestCase): for port_name, port in comp.output_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) del port1 del port2 @@ -670,9 +670,9 @@ class PortTestCase(unittest.TestCase): ): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") comp = self._create_comp(MyFilter) ports = [] @@ -680,11 +680,11 @@ class PortTestCase(unittest.TestCase): for port_name, port in comp.input_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) del port1 del port2 @@ -698,9 +698,9 @@ class PortTestCase(unittest.TestCase): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): nonlocal port1, port2, port3 - port1 = comp_self._add_input_port('clear') - port2 = comp_self._add_input_port('print') - port3 = comp_self._add_input_port('insert') + port1 = comp_self._add_input_port("clear") + port2 = comp_self._add_input_port("print") + port3 = comp_self._add_input_port("insert") def _user_consume(self): pass @@ -711,11 +711,11 @@ class PortTestCase(unittest.TestCase): for port_name, port in comp.input_ports.items(): ports.append((port_name, port)) - self.assertEqual(ports[0][0], 'clear') + self.assertEqual(ports[0][0], "clear") self.assertEqual(ports[0][1].addr, port1.addr) - self.assertEqual(ports[1][0], 'print') + self.assertEqual(ports[1][0], "print") self.assertEqual(ports[1][1].addr, port2.addr) - self.assertEqual(ports[2][0], 'insert') + self.assertEqual(ports[2][0], "insert") self.assertEqual(ports[2][1].addr, port3.addr) del port1 del port2 @@ -724,41 +724,41 @@ class PortTestCase(unittest.TestCase): def test_name(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') + comp_self._add_input_port("clear") def _user_consume(self): pass comp = self._create_comp(MySink) - self.assertEqual(comp.input_ports['clear'].name, 'clear') + self.assertEqual(comp.input_ports["clear"].name, "clear") def test_connection_none(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') + comp_self._add_input_port("clear") def _user_consume(self): pass comp = self._create_comp(MySink) - self.assertIsNone(comp.input_ports['clear'].connection) + self.assertIsNone(comp.input_ports["clear"].connection) def test_is_connected_false(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - comp_self._add_input_port('clear') + comp_self._add_input_port("clear") def _user_consume(self): pass comp = self._create_comp(MySink) - self.assertFalse(comp.input_ports['clear'].is_connected) + self.assertFalse(comp.input_ports["clear"].is_connected) def test_self_name(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port = comp_self._add_input_port('clear') - self.assertEqual(port.name, 'clear') + port = comp_self._add_input_port("clear") + self.assertEqual(port.name, "clear") def _user_consume(self): pass @@ -768,7 +768,7 @@ class PortTestCase(unittest.TestCase): def test_self_connection_none(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port = comp_self._add_input_port('clear') + port = comp_self._add_input_port("clear") self.assertIsNone(port.connection) def _user_consume(self): @@ -779,7 +779,7 @@ class PortTestCase(unittest.TestCase): def test_self_is_connected_false(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, config, params, obj): - port = comp_self._add_input_port('clear') + port = comp_self._add_input_port("clear") self.assertFalse(port.is_connected) def _user_consume(self): @@ -799,11 +799,11 @@ class PortTestCase(unittest.TestCase): def __init__(comp_self, config, params, obj): nonlocal user_datas - p = comp_self._add_output_port('port1') + p = comp_self._add_output_port("port1") user_datas.append(p.user_data) - p = comp_self._add_output_port('port2', 2) + p = comp_self._add_output_port("port2", 2) user_datas.append(p.user_data) - p = comp_self._add_output_port('port3', MyUserData()) + p = comp_self._add_output_port("port3", MyUserData()) user_datas.append(p.user_data) user_datas = [] @@ -833,18 +833,18 @@ class PortTestCase(unittest.TestCase): def __init__(comp_self, config, params, obj): nonlocal user_datas - p = comp_self._add_output_port('port1') + p = comp_self._add_output_port("port1") user_datas.append(p.user_data) - p = comp_self._add_output_port('port2', 'user data string') + p = comp_self._add_output_port("port2", "user data string") user_datas.append(p.user_data) - p = comp_self._add_output_port('port3', MyUserData()) + p = comp_self._add_output_port("port3", MyUserData()) user_datas.append(p.user_data) - p = comp_self._add_input_port('port4') + p = comp_self._add_input_port("port4") user_datas.append(p.user_data) - p = comp_self._add_input_port('port5', user_data={'user data': 'dict'}) + p = comp_self._add_input_port("port5", user_data={"user data": "dict"}) user_datas.append(p.user_data) - p = comp_self._add_input_port('port6', MyUserData()) + p = comp_self._add_input_port("port6", MyUserData()) user_datas.append(p.user_data) user_datas = [] @@ -853,10 +853,10 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MyFilter) self.assertEqual(len(user_datas), 6) self.assertIs(user_datas[0], None) - self.assertEqual(user_datas[1], 'user data string') + self.assertEqual(user_datas[1], "user data string") self.assertIs(type(user_datas[2]), MyUserData) self.assertIs(user_datas[3], None) - self.assertEqual(user_datas[4], {'user data': 'dict'}) + self.assertEqual(user_datas[4], {"user data": "dict"}) self.assertIs(type(user_datas[5]), MyUserData) # Verify that the user data gets freed. @@ -875,9 +875,9 @@ class PortTestCase(unittest.TestCase): def __init__(comp_self, config, params, obj): nonlocal user_datas - p = comp_self._add_input_port('port1') + p = comp_self._add_input_port("port1") user_datas.append(p.user_data) - p = comp_self._add_input_port('port2', MyUserData()) + p = comp_self._add_input_port("port2", MyUserData()) user_datas.append(p.user_data) def _user_consume(self): @@ -898,5 +898,5 @@ class PortTestCase(unittest.TestCase): self.assertEqual(objects_deleted, 1) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_query_executor.py b/tests/bindings/python/bt2/test_query_executor.py index e7186e88..0b7296a4 100644 --- a/tests/bindings/python/bt2/test_query_executor.py +++ b/tests/bindings/python/bt2/test_query_executor.py @@ -14,7 +14,7 @@ class QueryExecutorTestCase(unittest.TestCase): def _user_consume(self): pass - query_exec = bt2.QueryExecutor(MySink, 'obj') + query_exec = bt2.QueryExecutor(MySink, "obj") interrupter = query_exec.default_interrupter self.assertIs(type(interrupter), bt2.Interrupter) @@ -27,20 +27,20 @@ class QueryExecutorTestCase(unittest.TestCase): def _user_query(cls, priv_query_exec, obj, params, method_obj): nonlocal query_params query_params = params - return {'null': None, 'bt2': 'BT2'} + return {"null": None, "bt2": "BT2"} query_params = None params = { - 'array': ['coucou', 23, None], - 'other_map': {'yes': 'yeah', '19': 19, 'minus 1.5': -1.5}, - 'null': None, + "array": ["coucou", 23, None], + "other_map": {"yes": "yeah", "19": 19, "minus 1.5": -1.5}, + "null": None, } - res = bt2.QueryExecutor(MySink, 'obj', params).query() + res = bt2.QueryExecutor(MySink, "obj", params).query() self.assertIs(type(res), bt2._MapValueConst) - self.assertIs(type(res['bt2']), bt2._StringValueConst) + self.assertIs(type(res["bt2"]), bt2._StringValueConst) self.assertEqual(query_params, params) - self.assertEqual(res, {'null': None, 'bt2': 'BT2'}) + self.assertEqual(res, {"null": None, "bt2": "BT2"}) del query_params def test_query_params_none(self): @@ -54,7 +54,7 @@ class QueryExecutorTestCase(unittest.TestCase): query_params = params query_params = 23 - bt2.QueryExecutor(MySink, 'obj', None).query() + bt2.QueryExecutor(MySink, "obj", None).query() self.assertIs(query_params, None) del query_params @@ -69,7 +69,7 @@ class QueryExecutorTestCase(unittest.TestCase): query_params = params query_params = 23 - bt2.QueryExecutor(MySink, 'obj').query() + bt2.QueryExecutor(MySink, "obj").query() self.assertIs(query_params, None) del query_params @@ -85,7 +85,7 @@ class QueryExecutorTestCase(unittest.TestCase): query_method_obj = None method_obj = object() - bt2.QueryExecutor(MySink, 'obj', method_obj=method_obj).query() + bt2.QueryExecutor(MySink, "obj", method_obj=method_obj).query() self.assertIs(query_method_obj, method_obj) del query_method_obj @@ -104,12 +104,12 @@ class QueryExecutorTestCase(unittest.TestCase): query_method_obj = None method_obj = Custom() - method_obj.hola = 'hello' - query_exec = bt2.QueryExecutor(MySink, 'obj', method_obj=method_obj) + method_obj.hola = "hello" + query_exec = bt2.QueryExecutor(MySink, "obj", method_obj=method_obj) del method_obj query_exec.query() self.assertIsInstance(query_method_obj, Custom) - self.assertEqual(query_method_obj.hola, 'hello') + self.assertEqual(query_method_obj.hola, "hello") del query_method_obj def test_query_with_none_method_obj(self): @@ -123,21 +123,21 @@ class QueryExecutorTestCase(unittest.TestCase): query_method_obj = method_obj query_method_obj = object() - bt2.QueryExecutor(MySink, 'obj').query() + bt2.QueryExecutor(MySink, "obj").query() self.assertIsNone(query_method_obj) del query_method_obj def test_query_with_method_obj_non_python_comp_cls(self): - plugin = bt2.find_plugin('text', find_in_user_dir=False, find_in_sys_dir=False) + plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False) assert plugin is not None - cc = plugin.source_component_classes['dmesg'] + cc = plugin.source_component_classes["dmesg"] assert cc is not None with self.assertRaisesRegex( ValueError, - re.escape(r'cannot pass a Python object to a non-Python component class'), + re.escape(r"cannot pass a Python object to a non-Python component class"), ): - bt2.QueryExecutor(cc, 'obj', method_obj=object()).query() + bt2.QueryExecutor(cc, "obj", method_obj=object()).query() def test_query_logging_level(self): class MySink(bt2._UserSinkComponent): @@ -150,7 +150,7 @@ class QueryExecutorTestCase(unittest.TestCase): query_log_level = priv_query_exec.logging_level query_log_level = None - query_exec = bt2.QueryExecutor(MySink, 'obj', None) + query_exec = bt2.QueryExecutor(MySink, "obj", None) query_exec.logging_level = bt2.LoggingLevel.INFO query_exec.query() self.assertEqual(query_log_level, bt2.LoggingLevel.INFO) @@ -166,15 +166,15 @@ class QueryExecutorTestCase(unittest.TestCase): raise ValueError with self.assertRaises(bt2._Error) as ctx: - bt2.QueryExecutor(MySink, 'obj', [17, 23]).query() + bt2.QueryExecutor(MySink, "obj", [17, 23]).query() exc = ctx.exception self.assertEqual(len(exc), 3) cause = exc[0] self.assertIsInstance(cause, bt2._ComponentClassErrorCause) - self.assertIn('raise ValueError', cause.message) + self.assertIn("raise ValueError", cause.message) self.assertEqual(cause.component_class_type, bt2.ComponentClassType.SINK) - self.assertEqual(cause.component_class_name, 'MySink') + self.assertEqual(cause.component_class_name, "MySink") def test_query_unknown_object(self): class MySink(bt2._UserSinkComponent): @@ -186,7 +186,7 @@ class QueryExecutorTestCase(unittest.TestCase): raise bt2.UnknownObject with self.assertRaises(bt2.UnknownObject): - bt2.QueryExecutor(MySink, 'obj', [17, 23]).query() + bt2.QueryExecutor(MySink, "obj", [17, 23]).query() def test_query_logging_level_invalid_type(self): class MySink(bt2._UserSinkComponent): @@ -197,10 +197,10 @@ class QueryExecutorTestCase(unittest.TestCase): def _user_query(cls, priv_query_exec, obj, params, method_obj): pass - query_exec = bt2.QueryExecutor(MySink, 'obj', [17, 23]) + query_exec = bt2.QueryExecutor(MySink, "obj", [17, 23]) with self.assertRaises(TypeError): - query_exec.logging_level = 'yeah' + query_exec.logging_level = "yeah" def test_query_logging_level_invalid_value(self): class MySink(bt2._UserSinkComponent): @@ -211,7 +211,7 @@ class QueryExecutorTestCase(unittest.TestCase): def _user_query(cls, priv_query_exec, obj, params, method_obj): pass - query_exec = bt2.QueryExecutor(MySink, 'obj', [17, 23]) + query_exec = bt2.QueryExecutor(MySink, "obj", [17, 23]) with self.assertRaises(ValueError): query_exec.logging_level = 12345 @@ -226,7 +226,7 @@ class QueryExecutorTestCase(unittest.TestCase): raise bt2.TryAgain with self.assertRaises(bt2.TryAgain): - bt2.QueryExecutor(MySink, 'obj', [17, 23]).query() + bt2.QueryExecutor(MySink, "obj", [17, 23]).query() def test_query_add_interrupter(self): class MySink(bt2._UserSinkComponent): @@ -245,7 +245,7 @@ class QueryExecutorTestCase(unittest.TestCase): interrupter1 = bt2.Interrupter() interrupter2 = bt2.Interrupter() test_self = self - query_exec = bt2.QueryExecutor(MySink, 'obj', [17, 23]) + query_exec = bt2.QueryExecutor(MySink, "obj", [17, 23]) query_exec.add_interrupter(interrupter1) query_exec.add_interrupter(interrupter2) query_exec.query() @@ -262,7 +262,7 @@ class QueryExecutorTestCase(unittest.TestCase): test_self.assertTrue(query_exec.is_interrupted) test_self = self - query_exec = bt2.QueryExecutor(MySink, 'obj', [17, 23]) + query_exec = bt2.QueryExecutor(MySink, "obj", [17, 23]) query_exec.query() def test_query_priv_executor_invalid_after(self): @@ -276,7 +276,7 @@ class QueryExecutorTestCase(unittest.TestCase): test_priv_query_exec = priv_query_exec test_priv_query_exec = None - query_exec = bt2.QueryExecutor(MySink, 'obj', [17, 23]) + query_exec = bt2.QueryExecutor(MySink, "obj", [17, 23]) query_exec.query() assert test_priv_query_exec is not None @@ -286,5 +286,5 @@ class QueryExecutorTestCase(unittest.TestCase): del test_priv_query_exec -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_stream.py b/tests/bindings/python/bt2/test_stream.py index 997b211c..25dc5600 100644 --- a/tests/bindings/python/bt2/test_stream.py +++ b/tests/bindings/python/bt2/test_stream.py @@ -28,21 +28,21 @@ class StreamTestCase(unittest.TestCase): self.assertEqual(len(stream.user_attributes), 0) def test_name(self): - stream = self._tr.create_stream(self._sc, name='équidistant') - self.assertEqual(stream.name, 'équidistant') + stream = self._tr.create_stream(self._sc, name="équidistant") + self.assertEqual(stream.name, "équidistant") def test_invalid_name(self): with self.assertRaises(TypeError): self._tr.create_stream(self._sc, name=22) def test_create_user_attributes(self): - stream = self._tr.create_stream(self._sc, user_attributes={'salut': 23}) - self.assertEqual(stream.user_attributes, {'salut': 23}) + stream = self._tr.create_stream(self._sc, user_attributes={"salut": 23}) + self.assertEqual(stream.user_attributes, {"salut": 23}) self.assertIs(type(stream.user_attributes), bt2_value.MapValue) def test_const_user_attributes(self): stream = utils.get_const_stream_beginning_message().stream - self.assertEqual(stream.user_attributes, {'salut': 23}) + self.assertEqual(stream.user_attributes, {"salut": 23}) self.assertIs(type(stream.user_attributes), bt2_value._MapValueConst) def test_create_invalid_user_attributes(self): @@ -75,8 +75,8 @@ class StreamTestCase(unittest.TestCase): sc = self._tc.create_stream_class(assigns_automatic_stream_id=False) with self.assertRaises(TypeError): - self._tr.create_stream(sc, id='string') + self._tr.create_stream(sc, id="string") -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_stream_class.py b/tests/bindings/python/bt2/test_stream_class.py index f68be98d..09e6e5e0 100644 --- a/tests/bindings/python/bt2/test_stream_class.py +++ b/tests/bindings/python/bt2/test_stream_class.py @@ -42,8 +42,8 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(sc.user_attributes), 0) def test_create_name(self): - sc = self._tc.create_stream_class(name='bozo') - self.assertEqual(sc.name, 'bozo') + sc = self._tc.create_stream_class(name="bozo") + self.assertEqual(sc.name, "bozo") def test_create_invalid_name(self): with self.assertRaisesRegex(TypeError, "'int' is not a 'str' object"): @@ -115,8 +115,8 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(self._tc), 0) def test_create_user_attributes(self): - sc = self._tc.create_stream_class(user_attributes={'salut': 23}) - self.assertEqual(sc.user_attributes, {'salut': 23}) + sc = self._tc.create_stream_class(user_attributes={"salut": 23}) + self.assertEqual(sc.user_attributes, {"salut": 23}) def test_create_invalid_user_attributes(self): with self.assertRaisesRegex( @@ -155,7 +155,7 @@ class StreamClassTestCase(unittest.TestCase): def test_automatic_stream_ids_wrong_type(self): with self.assertRaisesRegex(TypeError, "str' is not a 'bool' object"): - self._tc.create_stream_class(assigns_automatic_stream_id='True') + self._tc.create_stream_class(assigns_automatic_stream_id="True") self.assertEqual(len(self._tc), 0) @@ -199,7 +199,7 @@ class StreamClassTestCase(unittest.TestCase): def test_automatic_event_class_ids_wrong_type(self): with self.assertRaisesRegex(TypeError, "'str' is not a 'bool' object"): - self._tc.create_stream_class(assigns_automatic_event_class_id='True') + self._tc.create_stream_class(assigns_automatic_event_class_id="True") self.assertEqual(len(self._tc), 0) @@ -349,7 +349,7 @@ class StreamClassTestCase(unittest.TestCase): ): with self.assertRaisesRegex( ValueError, - 'cannot have no default clock class, but have default clock snapshots for discarded event messages', + "cannot have no default clock class, but have default clock snapshots for discarded event messages", ): self._tc.create_stream_class( supports_discarded_events=True, @@ -425,7 +425,7 @@ class StreamClassTestCase(unittest.TestCase): ): with self.assertRaisesRegex( ValueError, - 'cannot have no default clock class, but have default clock snapshots for discarded packet messages', + "cannot have no default clock class, but have default clock snapshots for discarded packet messages", ): self._tc.create_stream_class( supports_packets=True, @@ -458,12 +458,12 @@ class StreamClassTestCase(unittest.TestCase): sc, _, _ = self._create_stream_class_with_event_classes() with self.assertRaisesRegex(TypeError, "'str' is not an 'int' object"): - sc['event23'] + sc["event23"] def test_getitem_wrong_key(self): sc, _, _ = self._create_stream_class_with_event_classes() - with self.assertRaisesRegex(KeyError, '19'): + with self.assertRaisesRegex(KeyError, "19"): sc[19] def test_len(self): @@ -478,5 +478,5 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(ec_ids, [17, 23]) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_trace.py b/tests/bindings/python/bt2/test_trace.py index d617539c..ad0ef39e 100644 --- a/tests/bindings/python/bt2/test_trace.py +++ b/tests/bindings/python/bt2/test_trace.py @@ -30,8 +30,8 @@ class TraceTestCase(unittest.TestCase): self._tc(name=17) def test_create_user_attributes(self): - trace = self._tc(user_attributes={'salut': 23}) - self.assertEqual(trace.user_attributes, {'salut': 23}) + trace = self._tc(user_attributes={"salut": 23}) + self.assertEqual(trace.user_attributes, {"salut": 23}) self.assertIs(type(trace.user_attributes), bt2_value.MapValue) def test_create_invalid_user_attributes(self): @@ -52,47 +52,47 @@ class TraceTestCase(unittest.TestCase): self.assertIs(type(trace.cls), bt2_trace_class._TraceClassConst) def test_attr_name(self): - trace = self._tc(name='mein trace') - self.assertEqual(trace.name, 'mein trace') + trace = self._tc(name="mein trace") + self.assertEqual(trace.name, "mein trace") def test_attr_uuid(self): - trace = self._tc(uuid=uuid.UUID('da7d6b6f-3108-4706-89bd-ab554732611b')) - self.assertEqual(trace.uuid, uuid.UUID('da7d6b6f-3108-4706-89bd-ab554732611b')) + trace = self._tc(uuid=uuid.UUID("da7d6b6f-3108-4706-89bd-ab554732611b")) + self.assertEqual(trace.uuid, uuid.UUID("da7d6b6f-3108-4706-89bd-ab554732611b")) def test_env_get(self): - trace = self._tc(environment={'hello': 'you', 'foo': -5}) + trace = self._tc(environment={"hello": "you", "foo": -5}) self.assertIs(type(trace.environment), bt2_trace._TraceEnvironment) - self.assertIs(type(trace.environment['foo']), bt2_value.SignedIntegerValue) - self.assertEqual(trace.environment['hello'], 'you') - self.assertEqual(trace.environment['foo'], -5) + self.assertIs(type(trace.environment["foo"]), bt2_value.SignedIntegerValue) + self.assertEqual(trace.environment["hello"], "you") + self.assertEqual(trace.environment["foo"], -5) def test_env_iter(self): - trace = self._tc(environment={'hello': 'you', 'foo': -5}) + trace = self._tc(environment={"hello": "you", "foo": -5}) values = set(trace.environment) - self.assertEqual(values, {'hello', 'foo'}) + self.assertEqual(values, {"hello", "foo"}) def test_const_env_get(self): trace = utils.get_const_stream_beginning_message().stream.trace self.assertIs(type(trace.environment), bt2_trace._TraceEnvironmentConst) self.assertIs( - type(trace.environment['patate']), bt2_value._SignedIntegerValueConst + type(trace.environment["patate"]), bt2_value._SignedIntegerValueConst ) def test_const_env_iter(self): trace = utils.get_const_stream_beginning_message().stream.trace values = set(trace.environment) - self.assertEqual(values, {'patate'}) + self.assertEqual(values, {"patate"}) def test_const_env_set(self): trace = utils.get_const_stream_beginning_message().stream.trace with self.assertRaises(TypeError): - trace.environment['patate'] = 33 + trace.environment["patate"] = 33 def test_env_get_non_existent(self): - trace = self._tc(environment={'hello': 'you', 'foo': -5}) + trace = self._tc(environment={"hello": "you", "foo": -5}) with self.assertRaises(KeyError): - trace.environment['lel'] + trace.environment["lel"] def test_len(self): trace = self._tc() @@ -200,7 +200,7 @@ class TraceTestCase(unittest.TestCase): with self.assertRaisesRegex( ValueError, - r'This trace destruction listener does not match the trace object\.', + r"This trace destruction listener does not match the trace object\.", ): trace2.remove_destruction_listener(handle1) @@ -215,13 +215,13 @@ class TraceTestCase(unittest.TestCase): trace.remove_destruction_listener(handle) with self.assertRaisesRegex( - ValueError, r'This trace destruction listener was already removed\.' + ValueError, r"This trace destruction listener was already removed\." ): trace.remove_destruction_listener(handle) def test_raise_in_destruction_listener(self): def on_trace_destruction(trace): - raise ValueError('it hurts') + raise ValueError("it hurts") trace_class = get_default_trace_class() trace = trace_class() @@ -230,5 +230,5 @@ class TraceTestCase(unittest.TestCase): del trace -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_trace_class.py b/tests/bindings/python/bt2/test_trace_class.py index 67f6456b..f9a21a0f 100644 --- a/tests/bindings/python/bt2/test_trace_class.py +++ b/tests/bindings/python/bt2/test_trace_class.py @@ -39,10 +39,10 @@ class TraceClassTestCase(unittest.TestCase): def test_create_user_attributes(self): def f(comp_self): - return comp_self._create_trace_class(user_attributes={'salut': 23}) + return comp_self._create_trace_class(user_attributes={"salut": 23}) tc = run_in_component_init(f) - self.assertEqual(tc.user_attributes, {'salut': 23}) + self.assertEqual(tc.user_attributes, {"salut": 23}) def test_create_invalid_user_attributes(self): def f(comp_self): @@ -59,7 +59,7 @@ class TraceClassTestCase(unittest.TestCase): def test_create_invalid_automatic_stream_class_id_type(self): def f(comp_self): return comp_self._create_trace_class( - assigns_automatic_stream_class_id='perchaude' + assigns_automatic_stream_class_id="perchaude" ) self.assertRaisesInComponentInit(TypeError, f) @@ -139,7 +139,7 @@ class TraceClassTestCase(unittest.TestCase): def test_getitem_wrong_key_type(self): tc, _, _, _ = self._create_trace_class_with_some_stream_classes() with self.assertRaises(TypeError): - tc['hello'] + tc["hello"] def test_getitem_wrong_key(self): tc, _, _, _ = self._create_trace_class_with_some_stream_classes() @@ -210,7 +210,7 @@ class TraceClassTestCase(unittest.TestCase): with self.assertRaisesRegex( ValueError, - r'This trace class destruction listener does not match the trace class object\.', + r"This trace class destruction listener does not match the trace class object\.", ): trace_class_2.remove_destruction_listener(handle1) @@ -224,13 +224,13 @@ class TraceClassTestCase(unittest.TestCase): trace_class.remove_destruction_listener(handle) with self.assertRaisesRegex( - ValueError, r'This trace class destruction listener was already removed\.' + ValueError, r"This trace class destruction listener was already removed\." ): trace_class.remove_destruction_listener(handle) def test_raise_in_destruction_listener(self): def on_trace_class_destruction(trace_class): - raise ValueError('it hurts') + raise ValueError("it hurts") trace_class = get_default_trace_class() trace_class.add_destruction_listener(on_trace_class_destruction) @@ -238,5 +238,5 @@ class TraceClassTestCase(unittest.TestCase): del trace_class -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py index f2ddb6d0..c9a6ebd7 100644 --- a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py +++ b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py @@ -10,20 +10,20 @@ import os import os.path -_BT_TESTS_DATADIR = os.environ['BT_TESTS_DATADIR'] -_BT_CTF_TRACES_PATH = os.environ['BT_CTF_TRACES_PATH'] +_BT_TESTS_DATADIR = os.environ["BT_TESTS_DATADIR"] +_BT_CTF_TRACES_PATH = os.environ["BT_CTF_TRACES_PATH"] _3EVENTS_INTERSECT_TRACE_PATH = os.path.join( - _BT_CTF_TRACES_PATH, 'intersection', '3eventsintersect' + _BT_CTF_TRACES_PATH, "intersection", "3eventsintersect" ) _NOINTERSECT_TRACE_PATH = os.path.join( - _BT_CTF_TRACES_PATH, 'intersection', 'nointersect' + _BT_CTF_TRACES_PATH, "intersection", "nointersect" ) -_SEQUENCE_TRACE_PATH = os.path.join(_BT_CTF_TRACES_PATH, 'succeed', 'sequence') +_SEQUENCE_TRACE_PATH = os.path.join(_BT_CTF_TRACES_PATH, "succeed", "sequence") _AUTO_SOURCE_DISCOVERY_GROUPING_PATH = os.path.join( - _BT_TESTS_DATADIR, 'auto-source-discovery', 'grouping' + _BT_TESTS_DATADIR, "auto-source-discovery", "grouping" ) _AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH = os.path.join( - _BT_TESTS_DATADIR, 'auto-source-discovery', 'params-log-level' + _BT_TESTS_DATADIR, "auto-source-discovery", "params-log-level" ) @@ -47,43 +47,43 @@ class _SomeSink(bt2._UserSinkComponent): class ComponentSpecTestCase(unittest.TestCase): def setUp(self): # A source CC from a plugin. - self._dmesg_cc = bt2.find_plugin('text').source_component_classes['dmesg'] + self._dmesg_cc = bt2.find_plugin("text").source_component_classes["dmesg"] assert self._dmesg_cc is not None # A filter CC from a plugin. - self._muxer_cc = bt2.find_plugin('utils').filter_component_classes['muxer'] + self._muxer_cc = bt2.find_plugin("utils").filter_component_classes["muxer"] assert self._muxer_cc is not None # A sink CC from a plugin. - self._pretty_cc = bt2.find_plugin('text').sink_component_classes['pretty'] + self._pretty_cc = bt2.find_plugin("text").sink_component_classes["pretty"] assert self._pretty_cc is not None def test_create_source_from_name(self): - spec = bt2.ComponentSpec.from_named_plugin_and_component_class('text', 'dmesg') - self.assertEqual(spec.component_class.name, 'dmesg') + spec = bt2.ComponentSpec.from_named_plugin_and_component_class("text", "dmesg") + self.assertEqual(spec.component_class.name, "dmesg") def test_create_source_from_plugin(self): spec = bt2.ComponentSpec(self._dmesg_cc) - self.assertEqual(spec.component_class.name, 'dmesg') + self.assertEqual(spec.component_class.name, "dmesg") def test_create_source_from_user(self): spec = bt2.ComponentSpec(_SomeSource) - self.assertEqual(spec.component_class.name, '_SomeSource') + self.assertEqual(spec.component_class.name, "_SomeSource") def test_create_filter_from_name(self): - spec = bt2.ComponentSpec.from_named_plugin_and_component_class('utils', 'muxer') - self.assertEqual(spec.component_class.name, 'muxer') + spec = bt2.ComponentSpec.from_named_plugin_and_component_class("utils", "muxer") + self.assertEqual(spec.component_class.name, "muxer") def test_create_filter_from_object(self): spec = bt2.ComponentSpec(self._muxer_cc) - self.assertEqual(spec.component_class.name, 'muxer') + self.assertEqual(spec.component_class.name, "muxer") def test_create_sink_from_name(self): with self.assertRaisesRegex( KeyError, - 'source or filter component class `pretty` not found in plugin `text`', + "source or filter component class `pretty` not found in plugin `text`", ): - bt2.ComponentSpec.from_named_plugin_and_component_class('text', 'pretty') + bt2.ComponentSpec.from_named_plugin_and_component_class("text", "pretty") def test_create_sink_from_object(self): with self.assertRaisesRegex( @@ -93,24 +93,24 @@ class ComponentSpecTestCase(unittest.TestCase): bt2.ComponentSpec(self._pretty_cc) def test_create_from_object_with_params(self): - spec = bt2.ComponentSpec(self._dmesg_cc, {'salut': 23}) - self.assertEqual(spec.params['salut'], 23) + spec = bt2.ComponentSpec(self._dmesg_cc, {"salut": 23}) + self.assertEqual(spec.params["salut"], 23) def test_create_from_name_with_params(self): spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'text', 'dmesg', {'salut': 23} + "text", "dmesg", {"salut": 23} ) - self.assertEqual(spec.params['salut'], 23) + self.assertEqual(spec.params["salut"], 23) def test_create_from_object_with_path_params(self): - spec = spec = bt2.ComponentSpec(self._dmesg_cc, 'a path') - self.assertEqual(spec.params['inputs'], ['a path']) + spec = spec = bt2.ComponentSpec(self._dmesg_cc, "a path") + self.assertEqual(spec.params["inputs"], ["a path"]) def test_create_from_name_with_path_params(self): spec = spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'text', 'dmesg', 'a path' + "text", "dmesg", "a path" ) - self.assertEqual(spec.params['inputs'], ['a path']) + self.assertEqual(spec.params["inputs"], ["a path"]) def test_create_wrong_comp_class_type(self): with self.assertRaisesRegex( @@ -120,19 +120,19 @@ class ComponentSpecTestCase(unittest.TestCase): def test_create_from_name_wrong_plugin_name_type(self): with self.assertRaisesRegex(TypeError, "'int' is not a 'str' object"): - bt2.ComponentSpec.from_named_plugin_and_component_class(23, 'compcls') + bt2.ComponentSpec.from_named_plugin_and_component_class(23, "compcls") def test_create_from_name_non_existent_plugin(self): with self.assertRaisesRegex( ValueError, "no such plugin: this_plugin_does_not_exist" ): bt2.ComponentSpec.from_named_plugin_and_component_class( - 'this_plugin_does_not_exist', 'compcls' + "this_plugin_does_not_exist", "compcls" ) def test_create_from_name_wrong_component_class_name_type(self): with self.assertRaisesRegex(TypeError, "'int' is not a 'str' object"): - bt2.ComponentSpec.from_named_plugin_and_component_class('utils', 190) + bt2.ComponentSpec.from_named_plugin_and_component_class("utils", 190) def test_create_wrong_params_type(self): with self.assertRaisesRegex( @@ -145,17 +145,17 @@ class ComponentSpecTestCase(unittest.TestCase): TypeError, "cannot create value object from 'datetime' object" ): bt2.ComponentSpec.from_named_plugin_and_component_class( - 'text', 'dmesg', datetime.datetime.now() + "text", "dmesg", datetime.datetime.now() ) def test_create_wrong_log_level_type(self): with self.assertRaisesRegex(TypeError, "'str' is not an 'int' object"): - bt2.ComponentSpec(self._dmesg_cc, logging_level='banane') + bt2.ComponentSpec(self._dmesg_cc, logging_level="banane") def test_create_from_name_wrong_log_level_type(self): with self.assertRaisesRegex(TypeError, "'str' is not an 'int' object"): bt2.ComponentSpec.from_named_plugin_and_component_class( - 'text', 'dmesg', logging_level='banane' + "text", "dmesg", logging_level="banane" ) @@ -177,7 +177,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_wrong_stream_intersection_mode_type(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] @@ -187,27 +187,27 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_wrong_begin_type(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] with self.assertRaises(TypeError): - bt2.TraceCollectionMessageIterator(specs, begin='hi') + bt2.TraceCollectionMessageIterator(specs, begin="hi") def test_create_wrong_end_type(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] with self.assertRaises(TypeError): - bt2.TraceCollectionMessageIterator(specs, begin='lel') + bt2.TraceCollectionMessageIterator(specs, begin="lel") def test_create_begin_s(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] bt2.TraceCollectionMessageIterator(specs, begin=19457.918232) @@ -215,7 +215,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_end_s(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] bt2.TraceCollectionMessageIterator(specs, end=123.12312) @@ -223,7 +223,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_begin_datetime(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] bt2.TraceCollectionMessageIterator(specs, begin=datetime.datetime.now()) @@ -231,7 +231,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_end_datetime(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] bt2.TraceCollectionMessageIterator(specs, end=datetime.datetime.now()) @@ -239,7 +239,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_no_intersection(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] msg_iter = bt2.TraceCollectionMessageIterator(specs) @@ -251,7 +251,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): # Same as the above, but we pass a single spec instead of a spec list. def test_iter_specs_not_list(self): spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) msg_iter = bt2.TraceCollectionMessageIterator(spec) msgs = list(msg_iter) @@ -261,10 +261,10 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_custom_filter(self): src_spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) flt_spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'utils', 'trimmer', {'end': '13515309.000000075'} + "utils", "trimmer", {"end": "13515309.000000075"} ) msg_iter = bt2.TraceCollectionMessageIterator(src_spec, flt_spec) hist = _count_msgs_by_type(msg_iter) @@ -273,7 +273,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_intersection(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] msg_iter = bt2.TraceCollectionMessageIterator( @@ -289,11 +289,11 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): # to the `babeltrace.trace-infos` query. specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', - 'fs', + "ctf", + "fs", { - 'inputs': [_3EVENTS_INTERSECT_TRACE_PATH], - 'clock-class-offset-s': 1000, + "inputs": [_3EVENTS_INTERSECT_TRACE_PATH], + "clock-class-offset-s": 1000, }, ) ] @@ -316,7 +316,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_no_intersection_two_traces(self): spec = bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) specs = [spec, spec] msg_iter = bt2.TraceCollectionMessageIterator(specs) @@ -328,7 +328,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_no_intersection_begin(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] msg_iter = bt2.TraceCollectionMessageIterator(specs, begin=13515309.000000023) @@ -338,7 +338,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_iter_no_intersection_end(self): specs = [ bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH + "ctf", "fs", _3EVENTS_INTERSECT_TRACE_PATH ) ] msg_iter = bt2.TraceCollectionMessageIterator(specs, end=13515309.000000075) @@ -373,7 +373,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): _3EVENTS_INTERSECT_TRACE_PATH, bt2.AutoSourceComponentSpec(_SEQUENCE_TRACE_PATH), bt2.ComponentSpec.from_named_plugin_and_component_class( - 'ctf', 'fs', _NOINTERSECT_TRACE_PATH + "ctf", "fs", _NOINTERSECT_TRACE_PATH ), ] ) @@ -385,22 +385,22 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_auto_source_component_non_existent(self): with self.assertRaisesRegex( RuntimeError, - 'Some auto source component specs did not produce any component', + "Some auto source component specs did not produce any component", ): # Test with one path known to contain a trace and one path known # to not contain any trace. bt2.TraceCollectionMessageIterator( - [_SEQUENCE_TRACE_PATH, '/this/path/better/not/exist'] + [_SEQUENCE_TRACE_PATH, "/this/path/better/not/exist"] ) class _TestAutoDiscoverSourceComponentSpecs(unittest.TestCase): def setUp(self): - self._saved_babeltrace_plugin_path = os.environ['BABELTRACE_PLUGIN_PATH'] - os.environ['BABELTRACE_PLUGIN_PATH'] += os.pathsep + self._plugin_path + self._saved_babeltrace_plugin_path = os.environ["BABELTRACE_PLUGIN_PATH"] + os.environ["BABELTRACE_PLUGIN_PATH"] += os.pathsep + self._plugin_path def tearDown(self): - os.environ['BABELTRACE_PLUGIN_PATH'] = self._saved_babeltrace_plugin_path + os.environ["BABELTRACE_PLUGIN_PATH"] = self._saved_babeltrace_plugin_path class TestAutoDiscoverSourceComponentSpecsGrouping( @@ -410,7 +410,7 @@ class TestAutoDiscoverSourceComponentSpecsGrouping( def test_grouping(self): specs = [ - bt2.AutoSourceComponentSpec('ABCDE'), + bt2.AutoSourceComponentSpec("ABCDE"), bt2.AutoSourceComponentSpec(_AUTO_SOURCE_DISCOVERY_GROUPING_PATH), ] it = bt2.TraceCollectionMessageIterator(specs) @@ -418,14 +418,14 @@ class TestAutoDiscoverSourceComponentSpecsGrouping( self.assertEqual(len(msgs), 8) - self.assertEqual(msgs[0].stream.name, 'TestSourceABCDE: ABCDE') - self.assertEqual(msgs[1].stream.name, 'TestSourceExt: aaa1, aaa2, aaa3') - self.assertEqual(msgs[2].stream.name, 'TestSourceExt: bbb1, bbb2') - self.assertEqual(msgs[3].stream.name, 'TestSourceExt: ccc1') - self.assertEqual(msgs[4].stream.name, 'TestSourceExt: ccc2') - self.assertEqual(msgs[5].stream.name, 'TestSourceExt: ccc3') - self.assertEqual(msgs[6].stream.name, 'TestSourceExt: ccc4') - self.assertEqual(msgs[7].stream.name, 'TestSourceSomeDir: some-dir') + self.assertEqual(msgs[0].stream.name, "TestSourceABCDE: ABCDE") + self.assertEqual(msgs[1].stream.name, "TestSourceExt: aaa1, aaa2, aaa3") + self.assertEqual(msgs[2].stream.name, "TestSourceExt: bbb1, bbb2") + self.assertEqual(msgs[3].stream.name, "TestSourceExt: ccc1") + self.assertEqual(msgs[4].stream.name, "TestSourceExt: ccc2") + self.assertEqual(msgs[5].stream.name, "TestSourceExt: ccc3") + self.assertEqual(msgs[6].stream.name, "TestSourceExt: ccc4") + self.assertEqual(msgs[7].stream.name, "TestSourceSomeDir: some-dir") class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( @@ -433,9 +433,9 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ): _plugin_path = _AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH - _dir_a = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, 'dir-a') - _dir_b = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, 'dir-b') - _dir_ab = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, 'dir-ab') + _dir_a = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, "dir-a") + _dir_b = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, "dir-b") + _dir_ab = os.path.join(_AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH, "dir-ab") def _test_two_comps_from_one_spec(self, params, obj=None, logging_level=None): specs = [ @@ -452,7 +452,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_params_two_comps_from_one_spec(self): msgs = self._test_two_comps_from_one_spec( - params={'test-allo': 'madame', 'what': 'test-params'} + params={"test-allo": "madame", "what": "test-params"} ) self.assertEqual(msgs[0].stream.name, "TestSourceA: ('test-allo', 'madame')") @@ -460,7 +460,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_two_comps_from_one_spec(self): msgs = self._test_two_comps_from_one_spec( - params={'what': 'python-obj'}, obj='deore' + params={"what": "python-obj"}, obj="deore" ) self.assertEqual(msgs[0].stream.name, "TestSourceA: deore") @@ -468,7 +468,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_log_level_two_comps_from_one_spec(self): msgs = self._test_two_comps_from_one_spec( - params={'what': 'log-level'}, logging_level=bt2.LoggingLevel.DEBUG + params={"what": "log-level"}, logging_level=bt2.LoggingLevel.DEBUG ) self.assertEqual( @@ -504,8 +504,8 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_params_two_comps_from_two_specs(self): msgs = self._test_two_comps_from_two_specs( - params_a={'test-allo': 'madame', 'what': 'test-params'}, - params_b={'test-bonjour': 'monsieur', 'what': 'test-params'}, + params_a={"test-allo": "madame", "what": "test-params"}, + params_b={"test-bonjour": "monsieur", "what": "test-params"}, ) self.assertEqual(msgs[0].stream.name, "TestSourceA: ('test-allo', 'madame')") @@ -515,10 +515,10 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_two_comps_from_two_specs(self): msgs = self._test_two_comps_from_two_specs( - params_a={'what': 'python-obj'}, - params_b={'what': 'python-obj'}, - obj_a='deore', - obj_b='alivio', + params_a={"what": "python-obj"}, + params_b={"what": "python-obj"}, + obj_a="deore", + obj_b="alivio", ) self.assertEqual(msgs[0].stream.name, "TestSourceA: deore") @@ -526,8 +526,8 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_log_level_two_comps_from_two_specs(self): msgs = self._test_two_comps_from_two_specs( - params_a={'what': 'log-level'}, - params_b={'what': 'log-level'}, + params_a={"what": "log-level"}, + params_b={"what": "log-level"}, logging_level_a=bt2.LoggingLevel.DEBUG, logging_level_b=bt2.LoggingLevel.TRACE, ) @@ -568,8 +568,8 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_params_one_comp_from_one_spec_one_comp_from_both_1(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_1( - params_a={'test-allo': 'madame', 'what': 'test-params'}, - params_ab={'test-bonjour': 'monsieur', 'what': 'test-params'}, + params_a={"test-allo": "madame", "what": "test-params"}, + params_ab={"test-bonjour": "monsieur", "what": "test-params"}, ) self.assertEqual( @@ -582,10 +582,10 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_one_comp_from_one_spec_one_comp_from_both_1(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_1( - params_a={'what': 'python-obj'}, - params_ab={'what': 'python-obj'}, - obj_a='deore', - obj_ab='alivio', + params_a={"what": "python-obj"}, + params_ab={"what": "python-obj"}, + obj_a="deore", + obj_ab="alivio", ) self.assertEqual(msgs[0].stream.name, "TestSourceA: alivio") @@ -593,8 +593,8 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_log_level_one_comp_from_one_spec_one_comp_from_both_1(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_1( - params_a={'what': 'log-level'}, - params_ab={'what': 'log-level'}, + params_a={"what": "log-level"}, + params_ab={"what": "log-level"}, logging_level_a=bt2.LoggingLevel.DEBUG, logging_level_ab=bt2.LoggingLevel.TRACE, ) @@ -636,11 +636,11 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_params_one_comp_from_one_spec_one_comp_from_both_2(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_2( params_ab={ - 'test-bonjour': 'madame', - 'test-salut': 'les amis', - 'what': 'test-params', + "test-bonjour": "madame", + "test-salut": "les amis", + "what": "test-params", }, - params_a={'test-bonjour': 'monsieur', 'what': 'test-params'}, + params_a={"test-bonjour": "monsieur", "what": "test-params"}, ) self.assertEqual( @@ -654,10 +654,10 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_one_comp_from_one_spec_one_comp_from_both_2(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_2( - params_ab={'what': 'python-obj'}, - params_a={'what': 'python-obj'}, - obj_ab='deore', - obj_a='alivio', + params_ab={"what": "python-obj"}, + params_a={"what": "python-obj"}, + obj_ab="deore", + obj_a="alivio", ) self.assertEqual(msgs[0].stream.name, "TestSourceA: alivio") @@ -665,8 +665,8 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_log_level_one_comp_from_one_spec_one_comp_from_both_2(self): msgs = self._test_one_comp_from_one_spec_one_comp_from_both_2( - params_ab={'what': 'log-level'}, - params_a={'what': 'log-level'}, + params_ab={"what": "log-level"}, + params_a={"what": "log-level"}, logging_level_ab=bt2.LoggingLevel.DEBUG, logging_level_a=bt2.LoggingLevel.TRACE, ) @@ -681,10 +681,10 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_override_with_none(self): specs = [ bt2.AutoSourceComponentSpec( - self._dir_ab, params={'what': 'python-obj'}, obj='deore' + self._dir_ab, params={"what": "python-obj"}, obj="deore" ), bt2.AutoSourceComponentSpec( - self._dir_a, params={'what': 'python-obj'}, obj=None + self._dir_a, params={"what": "python-obj"}, obj=None ), ] it = bt2.TraceCollectionMessageIterator(specs) @@ -697,9 +697,9 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( def test_obj_no_override_with_no_obj(self): specs = [ bt2.AutoSourceComponentSpec( - self._dir_ab, params={'what': 'python-obj'}, obj='deore' + self._dir_ab, params={"what": "python-obj"}, obj="deore" ), - bt2.AutoSourceComponentSpec(self._dir_a, params={'what': 'python-obj'}), + bt2.AutoSourceComponentSpec(self._dir_a, params={"what": "python-obj"}), ] it = bt2.TraceCollectionMessageIterator(specs) msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] @@ -709,5 +709,5 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( self.assertEqual(msgs[1].stream.name, "TestSourceB: deore") -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/test_value.py b/tests/bindings/python/bt2/test_value.py index e7f2ba2a..62b09888 100644 --- a/tests/bindings/python/bt2/test_value.py +++ b/tests/bindings/python/bt2/test_value.py @@ -489,36 +489,36 @@ class _TestNumericValue(_TestCopySimple): # Each entry is a pair of binary operator name (used as part of the # created testing method's name) and operator function. _BINOPS = ( - ('lt', operator.lt), - ('le', operator.le), - ('eq', operator.eq), - ('ne', operator.ne), - ('ge', operator.ge), - ('gt', operator.gt), - ('add', operator.add), - ('radd', lambda a, b: operator.add(b, a)), - ('and', operator.and_), - ('rand', lambda a, b: operator.and_(b, a)), - ('floordiv', operator.floordiv), - ('rfloordiv', lambda a, b: operator.floordiv(b, a)), - ('lshift', operator.lshift), - ('rlshift', lambda a, b: operator.lshift(b, a)), - ('mod', operator.mod), - ('rmod', lambda a, b: operator.mod(b, a)), - ('mul', operator.mul), - ('rmul', lambda a, b: operator.mul(b, a)), - ('or', operator.or_), - ('ror', lambda a, b: operator.or_(b, a)), - ('pow', operator.pow), - ('rpow', lambda a, b: operator.pow(b, a)), - ('rshift', operator.rshift), - ('rrshift', lambda a, b: operator.rshift(b, a)), - ('sub', operator.sub), - ('rsub', lambda a, b: operator.sub(b, a)), - ('truediv', operator.truediv), - ('rtruediv', lambda a, b: operator.truediv(b, a)), - ('xor', operator.xor), - ('rxor', lambda a, b: operator.xor(b, a)), + ("lt", operator.lt), + ("le", operator.le), + ("eq", operator.eq), + ("ne", operator.ne), + ("ge", operator.ge), + ("gt", operator.gt), + ("add", operator.add), + ("radd", lambda a, b: operator.add(b, a)), + ("and", operator.and_), + ("rand", lambda a, b: operator.and_(b, a)), + ("floordiv", operator.floordiv), + ("rfloordiv", lambda a, b: operator.floordiv(b, a)), + ("lshift", operator.lshift), + ("rlshift", lambda a, b: operator.lshift(b, a)), + ("mod", operator.mod), + ("rmod", lambda a, b: operator.mod(b, a)), + ("mul", operator.mul), + ("rmul", lambda a, b: operator.mul(b, a)), + ("or", operator.or_), + ("ror", lambda a, b: operator.or_(b, a)), + ("pow", operator.pow), + ("rpow", lambda a, b: operator.pow(b, a)), + ("rshift", operator.rshift), + ("rrshift", lambda a, b: operator.rshift(b, a)), + ("sub", operator.sub), + ("rsub", lambda a, b: operator.sub(b, a)), + ("truediv", operator.truediv), + ("rtruediv", lambda a, b: operator.truediv(b, a)), + ("xor", operator.xor), + ("rxor", lambda a, b: operator.xor(b, a)), ) @@ -528,18 +528,18 @@ _BINOPS = ( # Each entry is a pair of unary operator name (used as part of the # created testing method's name) and operator function. _UNARYOPS = ( - ('neg', operator.neg), - ('pos', operator.pos), - ('abs', operator.abs), - ('invert', operator.invert), - ('round', round), - ('round_0', partial(round, ndigits=0)), - ('round_1', partial(round, ndigits=1)), - ('round_2', partial(round, ndigits=2)), - ('round_3', partial(round, ndigits=3)), - ('ceil', math.ceil), - ('floor', math.floor), - ('trunc', math.trunc), + ("neg", operator.neg), + ("pos", operator.pos), + ("abs", operator.abs), + ("invert", operator.invert), + ("round", round), + ("round_0", partial(round, ndigits=0)), + ("round_1", partial(round, ndigits=1)), + ("round_2", partial(round, ndigits=2)), + ("round_3", partial(round, ndigits=3)), + ("ceil", math.ceil), + ("floor", math.floor), + ("trunc", math.trunc), ) @@ -559,395 +559,395 @@ _UNARYOPS = ( # method, for each unary operator in the _UNARYOPS tuple. def _inject_numeric_testing_methods(cls): def test_binop_name(suffix): - return 'test_binop_{}_{}'.format(name, suffix) + return "test_binop_{}_{}".format(name, suffix) def test_unaryop_name(suffix): - return 'test_unaryop_{}_{}'.format(name, suffix) + return "test_unaryop_{}_{}".format(name, suffix) # inject testing methods for each binary operation for name, binop in _BINOPS: setattr( cls, - test_binop_name('unknown'), + test_binop_name("unknown"), partialmethod(_TestNumericValue._test_binop_unknown, op=binop), ) setattr( cls, - test_binop_name('none'), + test_binop_name("none"), partialmethod(_TestNumericValue._test_binop_none, op=binop), ) setattr( cls, - test_binop_name('type_true'), + test_binop_name("type_true"), partialmethod(_TestNumericValue._test_binop_type_true, op=binop), ) setattr( cls, - test_binop_name('type_pos_int'), + test_binop_name("type_pos_int"), partialmethod(_TestNumericValue._test_binop_type_pos_int, op=binop), ) setattr( cls, - test_binop_name('type_pos_vint'), + test_binop_name("type_pos_vint"), partialmethod(_TestNumericValue._test_binop_type_pos_vint, op=binop), ) setattr( cls, - test_binop_name('value_true'), + test_binop_name("value_true"), partialmethod(_TestNumericValue._test_binop_value_true, op=binop), ) setattr( cls, - test_binop_name('value_pos_int'), + test_binop_name("value_pos_int"), partialmethod(_TestNumericValue._test_binop_value_pos_int, op=binop), ) setattr( cls, - test_binop_name('value_pos_vint'), + test_binop_name("value_pos_vint"), partialmethod(_TestNumericValue._test_binop_value_pos_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_true'), + test_binop_name("lhs_addr_same_true"), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_true, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_int'), + test_binop_name("lhs_addr_same_pos_int"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_pos_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_vint'), + test_binop_name("lhs_addr_same_pos_vint"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_pos_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_true'), + test_binop_name("lhs_value_same_true"), partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop), ) setattr( cls, - test_binop_name('lhs_value_same_pos_int'), + test_binop_name("lhs_value_same_pos_int"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_vint'), + test_binop_name("lhs_value_same_pos_vint"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop ), ) setattr( cls, - test_binop_name('type_neg_int'), + test_binop_name("type_neg_int"), partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop), ) setattr( cls, - test_binop_name('type_neg_vint'), + test_binop_name("type_neg_vint"), partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop), ) setattr( cls, - test_binop_name('value_neg_int'), + test_binop_name("value_neg_int"), partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop), ) setattr( cls, - test_binop_name('value_neg_vint'), + test_binop_name("value_neg_vint"), partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_int'), + test_binop_name("lhs_addr_same_neg_int"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_vint'), + test_binop_name("lhs_addr_same_neg_vint"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_int'), + test_binop_name("lhs_value_same_neg_int"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_vint'), + test_binop_name("lhs_value_same_neg_vint"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop ), ) setattr( cls, - test_binop_name('type_false'), + test_binop_name("type_false"), partialmethod(_TestNumericValue._test_binop_type_false, op=binop), ) setattr( cls, - test_binop_name('type_zero_int'), + test_binop_name("type_zero_int"), partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop), ) setattr( cls, - test_binop_name('type_zero_vint'), + test_binop_name("type_zero_vint"), partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop), ) setattr( cls, - test_binop_name('value_false'), + test_binop_name("value_false"), partialmethod(_TestNumericValue._test_binop_value_false, op=binop), ) setattr( cls, - test_binop_name('value_zero_int'), + test_binop_name("value_zero_int"), partialmethod(_TestNumericValue._test_binop_value_zero_int, op=binop), ) setattr( cls, - test_binop_name('value_zero_vint'), + test_binop_name("value_zero_vint"), partialmethod(_TestNumericValue._test_binop_value_zero_vint, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_false'), + test_binop_name("lhs_addr_same_false"), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_false, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_int'), + test_binop_name("lhs_addr_same_zero_int"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_zero_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_vint'), + test_binop_name("lhs_addr_same_zero_vint"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_zero_vint, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_false'), + test_binop_name("lhs_value_same_false"), partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop), ) setattr( cls, - test_binop_name('lhs_value_same_zero_int'), + test_binop_name("lhs_value_same_zero_int"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_vint'), + test_binop_name("lhs_value_same_zero_vint"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop ), ) setattr( cls, - test_binop_name('type_neg_float'), + test_binop_name("type_neg_float"), partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop), ) setattr( cls, - test_binop_name('type_neg_vfloat'), + test_binop_name("type_neg_vfloat"), partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_neg_float'), + test_binop_name("value_neg_float"), partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop), ) setattr( cls, - test_binop_name('value_neg_vfloat'), + test_binop_name("value_neg_vfloat"), partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_float'), + test_binop_name("lhs_addr_same_neg_float"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_neg_vfloat'), + test_binop_name("lhs_addr_same_neg_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_float'), + test_binop_name("lhs_value_same_neg_float"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_neg_vfloat'), + test_binop_name("lhs_value_same_neg_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop ), ) setattr( cls, - test_binop_name('type_pos_float'), + test_binop_name("type_pos_float"), partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop), ) setattr( cls, - test_binop_name('type_pos_vfloat'), + test_binop_name("type_pos_vfloat"), partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_pos_float'), + test_binop_name("value_pos_float"), partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop), ) setattr( cls, - test_binop_name('value_pos_vfloat'), + test_binop_name("value_pos_vfloat"), partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_float'), + test_binop_name("lhs_addr_same_pos_float"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_pos_vfloat'), + test_binop_name("lhs_addr_same_pos_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_float'), + test_binop_name("lhs_value_same_pos_float"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_pos_vfloat'), + test_binop_name("lhs_value_same_pos_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop ), ) setattr( cls, - test_binop_name('type_zero_float'), + test_binop_name("type_zero_float"), partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop), ) setattr( cls, - test_binop_name('type_zero_vfloat'), + test_binop_name("type_zero_vfloat"), partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop), ) setattr( cls, - test_binop_name('value_zero_float'), + test_binop_name("value_zero_float"), partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop), ) setattr( cls, - test_binop_name('value_zero_vfloat'), + test_binop_name("value_zero_vfloat"), partialmethod(_TestNumericValue._test_binop_value_zero_vfloat, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_float'), + test_binop_name("lhs_addr_same_zero_float"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_zero_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_vfloat'), + test_binop_name("lhs_addr_same_zero_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_zero_vfloat, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_float'), + test_binop_name("lhs_value_same_zero_float"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_zero_float, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_vfloat'), + test_binop_name("lhs_value_same_zero_vfloat"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_zero_vfloat, op=binop ), ) setattr( cls, - test_binop_name('type_complex'), + test_binop_name("type_complex"), partialmethod(_TestNumericValue._test_binop_type_complex, op=binop), ) setattr( cls, - test_binop_name('type_zero_complex'), + test_binop_name("type_zero_complex"), partialmethod(_TestNumericValue._test_binop_type_zero_complex, op=binop), ) setattr( cls, - test_binop_name('value_complex'), + test_binop_name("value_complex"), partialmethod(_TestNumericValue._test_binop_value_complex, op=binop), ) setattr( cls, - test_binop_name('value_zero_complex'), + test_binop_name("value_zero_complex"), partialmethod(_TestNumericValue._test_binop_value_zero_complex, op=binop), ) setattr( cls, - test_binop_name('lhs_addr_same_complex'), + test_binop_name("lhs_addr_same_complex"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_addr_same_zero_complex'), + test_binop_name("lhs_addr_same_zero_complex"), partialmethod( _TestNumericValue._test_binop_lhs_addr_same_zero_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_complex'), + test_binop_name("lhs_value_same_complex"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_complex, op=binop ), ) setattr( cls, - test_binop_name('lhs_value_same_zero_complex'), + test_binop_name("lhs_value_same_zero_complex"), partialmethod( _TestNumericValue._test_binop_lhs_value_same_zero_complex, op=binop ), @@ -957,22 +957,22 @@ def _inject_numeric_testing_methods(cls): for name, unaryop in _UNARYOPS: setattr( cls, - test_unaryop_name('type'), + test_unaryop_name("type"), partialmethod(_TestNumericValue._test_unaryop_type, op=unaryop), ) setattr( cls, - test_unaryop_name('value'), + test_unaryop_name("value"), partialmethod(_TestNumericValue._test_unaryop_value, op=unaryop), ) setattr( cls, - test_unaryop_name('addr_same'), + test_unaryop_name("addr_same"), partialmethod(_TestNumericValue._test_unaryop_addr_same, op=unaryop), ) setattr( cls, - test_unaryop_name('value_same'), + test_unaryop_name("value_same"), partialmethod(_TestNumericValue._test_unaryop_value_same, op=unaryop), ) @@ -1017,13 +1017,13 @@ class CreateValueFuncTestCase(unittest.TestCase): self.assertEqual(v, raw) def test_create_string(self): - raw = 'salut' + raw = "salut" v = bt2.create_value(raw) self.assertIsInstance(v, bt2.StringValue) self.assertEqual(v, raw) def test_create_string_empty(self): - raw = '' + raw = "" v = bt2.create_value(raw) self.assertIsInstance(v, bt2.StringValue) self.assertEqual(v, raw) @@ -1053,7 +1053,7 @@ class CreateValueFuncTestCase(unittest.TestCase): self.assertEqual(v, raw) def test_create_map(self): - raw = {'salut': 23} + raw = {"salut": 23} v = bt2.create_value(raw) self.assertIsInstance(v, bt2.MapValue) self.assertEqual(v, raw) @@ -1089,10 +1089,10 @@ def _create_const_value(value): @classmethod def _user_query(cls, priv_query_exec, obj, params, method_obj): nonlocal value - return {'my_value': value} + return {"my_value": value} - res = bt2.QueryExecutor(MySink, 'obj', None).query() - return res['my_value'] + res = bt2.QueryExecutor(MySink, "obj", None).query() + return res["my_value"] class BoolValueTestCase(_TestNumericValue, unittest.TestCase): @@ -1208,7 +1208,7 @@ class _TestIntegerValue(_TestNumericValue): del self._def_value def _assert_expecting_int(self): - return self.assertRaisesRegex(TypeError, r'expecting an integral number object') + return self.assertRaisesRegex(TypeError, r"expecting an integral number object") def _assert_expecting_int64(self): return self.assertRaisesRegex( @@ -1453,10 +1453,10 @@ _inject_numeric_testing_methods(RealValueTestCase) class StringValueTestCase(_TestCopySimple, unittest.TestCase): def setUp(self): - self._def_value = 'Hello, World!' + self._def_value = "Hello, World!" self._def = bt2.StringValue(self._def_value) self._def_const = _create_const_value(self._def_value) - self._def_new_value = 'Yes!' + self._def_new_value = "Yes!" def tearDown(self): del self._def @@ -1466,15 +1466,15 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase): def test_create_default(self): s = bt2.StringValue() - self.assertEqual(s, '') + self.assertEqual(s, "") def test_create_from_str(self): - raw = 'liberté' + raw = "liberté" s = bt2.StringValue(raw) self.assertEqual(s, raw) def test_create_from_vstr(self): - raw = 'liberté' + raw = "liberté" s = bt2.StringValue(bt2.create_value(raw)) self.assertEqual(s, raw) @@ -1494,12 +1494,12 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase): self._def.value = 283 def test_assign_str(self): - raw = 'zorg' + raw = "zorg" self._def = raw self.assertEqual(self._def, raw) def test_assign_vstr(self): - raw = 'zorg' + raw = "zorg" self._def = bt2.create_value(raw) self.assertEqual(self._def, raw) @@ -1513,48 +1513,48 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase): self.assertNotEqual(self._def, 23) def test_lt_vstring(self): - s1 = bt2.StringValue('allo') - s2 = bt2.StringValue('bateau') + s1 = bt2.StringValue("allo") + s2 = bt2.StringValue("bateau") self.assertLess(s1, s2) def test_lt_string(self): - s1 = bt2.StringValue('allo') - self.assertLess(s1, 'bateau') + s1 = bt2.StringValue("allo") + self.assertLess(s1, "bateau") def test_le_vstring(self): - s1 = bt2.StringValue('allo') - s2 = bt2.StringValue('bateau') + s1 = bt2.StringValue("allo") + s2 = bt2.StringValue("bateau") self.assertLessEqual(s1, s2) def test_le_string(self): - s1 = bt2.StringValue('allo') - self.assertLessEqual(s1, 'bateau') + s1 = bt2.StringValue("allo") + self.assertLessEqual(s1, "bateau") def test_gt_vstring(self): - s1 = bt2.StringValue('allo') - s2 = bt2.StringValue('bateau') + s1 = bt2.StringValue("allo") + s2 = bt2.StringValue("bateau") self.assertGreater(s2, s1) def test_gt_string(self): - s1 = bt2.StringValue('allo') - self.assertGreater('bateau', s1) + s1 = bt2.StringValue("allo") + self.assertGreater("bateau", s1) def test_ge_vstring(self): - s1 = bt2.StringValue('allo') - s2 = bt2.StringValue('bateau') + s1 = bt2.StringValue("allo") + s2 = bt2.StringValue("bateau") self.assertGreaterEqual(s2, s1) def test_ge_string(self): - s1 = bt2.StringValue('allo') - self.assertGreaterEqual('bateau', s1) + s1 = bt2.StringValue("allo") + self.assertGreaterEqual("bateau", s1) def test_in_string(self): - s1 = bt2.StringValue('beau grand bateau') - self.assertIn('bateau', s1) + s1 = bt2.StringValue("beau grand bateau") + self.assertIn("bateau", s1) def test_in_vstring(self): - s1 = bt2.StringValue('beau grand bateau') - s2 = bt2.StringValue('bateau') + s1 = bt2.StringValue("beau grand bateau") + s2 = bt2.StringValue("bateau") self.assertIn(s2, s1) def test_bool_op(self): @@ -1573,20 +1573,20 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase): self.assertEqual(self._def_const[5], self._def_value[5]) def test_iadd_str(self): - to_append = 'meow meow meow' + to_append = "meow meow meow" self._def += to_append self._def_value += to_append self.assertEqual(self._def, self._def_value) def test_const_iadd_str(self): - to_append = 'meow meow meow' + to_append = "meow meow meow" with self.assertRaises(TypeError): self._def_const += to_append self.assertEqual(self._def_const, self._def_value) def test_append_vstr(self): - to_append = 'meow meow meow' + to_append = "meow meow meow" self._def += bt2.create_value(to_append) self._def_value += to_append self.assertEqual(self._def, self._def_value) @@ -1594,7 +1594,7 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase): class ArrayValueTestCase(_TestCopySimple, unittest.TestCase): def setUp(self): - self._def_value = [None, False, True, -23, 0, 42, -42.4, 23.17, 'yes'] + self._def_value = [None, False, True, -23, 0, 42, -42.4, 23.17, "yes"] self._def = bt2.ArrayValue(copy.deepcopy(self._def_value)) self._def_const = _create_const_value(copy.deepcopy(self._def_value)) @@ -1602,7 +1602,7 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase): del self._def def _modify_def(self): - self._def[2] = 'xyz' + self._def[2] = "xyz" def _assert_type_error(self): return self.assertRaises(TypeError) @@ -1661,7 +1661,7 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase): self.assertNotEqual(a1, a2) def test_eq_same_content_same_len(self): - raw = (3, True, [1, 2.5, None, {'a': 17.6, 'b': None}]) + raw = (3, True, [1, 2.5, None, {"a": 17.6, "b": None}]) a1 = bt2.ArrayValue(raw) a2 = bt2.ArrayValue(copy.deepcopy(raw)) self.assertEqual(a1, a2) @@ -1688,7 +1688,7 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase): def test_setitem_index_wrong_type(self): with self._assert_type_error(): - self._def['yes'] = 23 + self._def["yes"] = 23 def test_setitem_index_neg(self): with self.assertRaises(IndexError): @@ -1779,21 +1779,21 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase): self.assertEqual(item4, 23.17) self.assertIs(type(item5), bt2._StringValueConst) - self.assertEqual(item5, 'yes') + self.assertEqual(item5, "yes") class MapValueTestCase(_TestCopySimple, unittest.TestCase): def setUp(self): self._def_value = { - 'none': None, - 'false': False, - 'true': True, - 'neg-int': -23, - 'zero': 0, - 'pos-int': 42, - 'neg-float': -42.4, - 'pos-float': 23.17, - 'str': 'yes', + "none": None, + "false": False, + "true": True, + "neg-int": -23, + "zero": 0, + "pos-int": 42, + "neg-float": -42.4, + "pos-float": 23.17, + "str": "yes", } self._def = bt2.MapValue(copy.deepcopy(self._def_value)) self._def_const = _create_const_value(self._def_value) @@ -1802,7 +1802,7 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase): del self._def def _modify_def(self): - self._def['zero'] = 1 + self._def["zero"] = 1 def test_create_default(self): m = bt2.MapValue() @@ -1833,52 +1833,52 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase): self.assertEqual(len(self._def), len(self._def_value)) def test_const_eq(self): - a1 = _create_const_value({'a': 1, 'b': 2, 'c': 3}) - a2 = {'a': 1, 'b': 2, 'c': 3} + a1 = _create_const_value({"a": 1, "b": 2, "c": 3}) + a2 = {"a": 1, "b": 2, "c": 3} self.assertEqual(a1, a2) def test_eq_int(self): self.assertNotEqual(self._def, 23) def test_eq_diff_len(self): - a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3}) - a2 = bt2.create_value({'a': 1, 'b': 2}) + a1 = bt2.create_value({"a": 1, "b": 2, "c": 3}) + a2 = bt2.create_value({"a": 1, "b": 2}) self.assertNotEqual(a1, a2) def test_const_eq_diff_len(self): - a1 = _create_const_value({'a': 1, 'b': 2, 'c': 3}) - a2 = _create_const_value({'a': 1, 'b': 2}) + a1 = _create_const_value({"a": 1, "b": 2, "c": 3}) + a2 = _create_const_value({"a": 1, "b": 2}) self.assertNotEqual(a1, a2) def test_eq_diff_content_same_len(self): - a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3}) - a2 = bt2.create_value({'a': 4, 'b': 2, 'c': 3}) + a1 = bt2.create_value({"a": 1, "b": 2, "c": 3}) + a2 = bt2.create_value({"a": 4, "b": 2, "c": 3}) self.assertNotEqual(a1, a2) def test_const_eq_diff_content_same_len(self): - a1 = _create_const_value({'a': 1, 'b': 2, 'c': 3}) - a2 = _create_const_value({'a': 4, 'b': 2, 'c': 3}) + a1 = _create_const_value({"a": 1, "b": 2, "c": 3}) + a2 = _create_const_value({"a": 4, "b": 2, "c": 3}) self.assertNotEqual(a1, a2) def test_eq_same_content_diff_keys(self): - a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3}) - a2 = bt2.create_value({'a': 1, 'k': 2, 'c': 3}) + a1 = bt2.create_value({"a": 1, "b": 2, "c": 3}) + a2 = bt2.create_value({"a": 1, "k": 2, "c": 3}) self.assertNotEqual(a1, a2) def test_const_eq_same_content_diff_keys(self): - a1 = _create_const_value({'a': 1, 'b': 2, 'c': 3}) - a2 = _create_const_value({'a': 1, 'k': 2, 'c': 3}) + a1 = _create_const_value({"a": 1, "b": 2, "c": 3}) + a2 = _create_const_value({"a": 1, "k": 2, "c": 3}) self.assertNotEqual(a1, a2) def test_eq_same_content_same_len(self): - raw = {'3': 3, 'True': True, 'array': [1, 2.5, None, {'a': 17.6, 'b': None}]} + raw = {"3": 3, "True": True, "array": [1, 2.5, None, {"a": 17.6, "b": None}]} a1 = bt2.MapValue(raw) a2 = bt2.MapValue(copy.deepcopy(raw)) self.assertEqual(a1, a2) self.assertEqual(a1, raw) def test_const_eq_same_content_same_len(self): - raw = {'3': 3, 'True': True, 'array': [1, 2.5, None, {'a': 17.6, 'b': None}]} + raw = {"3": 3, "True": True, "array": [1, 2.5, None, {"a": 17.6, "b": None}]} a1 = _create_const_value(raw) a2 = _create_const_value(copy.deepcopy(raw)) self.assertEqual(a1, a2) @@ -1886,26 +1886,26 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase): def test_setitem_int(self): raw = 19 - self._def['pos-int'] = raw - self.assertEqual(self._def['pos-int'], raw) + self._def["pos-int"] = raw + self.assertEqual(self._def["pos-int"], raw) def test_const_setitem_int(self): with self.assertRaises(TypeError): - self._def_const['pos-int'] = 19 + self._def_const["pos-int"] = 19 def test_setitem_vint(self): raw = 19 - self._def['pos-int'] = bt2.create_value(raw) - self.assertEqual(self._def['pos-int'], raw) + self._def["pos-int"] = bt2.create_value(raw) + self.assertEqual(self._def["pos-int"], raw) def test_setitem_none(self): - self._def['none'] = None - self.assertIsNone(self._def['none']) + self._def["none"] = None + self.assertIsNone(self._def["none"]) def test_setitem_new_int(self): old_len = len(self._def) - self._def['new-int'] = 23 - self.assertEqual(self._def['new-int'], 23) + self._def["new-int"] = 23 + self.assertEqual(self._def["new-int"], 23) self.assertEqual(len(self._def), old_len + 1) def test_setitem_index_wrong_type(self): @@ -1923,16 +1923,16 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase): self.assertEqual(vval, val) def test_get_item(self): - i = self._def['pos-float'] + i = self._def["pos-float"] self.assertIs(type(i), bt2.RealValue) self.assertEqual(i, 23.17) def test_const_get_item(self): - item1 = self._def_const['none'] - item2 = self._def_const['true'] - item3 = self._def_const['pos-int'] - item4 = self._def_const['pos-float'] - item5 = self._def_const['str'] + item1 = self._def_const["none"] + item2 = self._def_const["true"] + item3 = self._def_const["pos-int"] + item4 = self._def_const["pos-float"] + item5 = self._def_const["str"] self.assertEqual(item1, None) @@ -1946,12 +1946,12 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase): self.assertEqual(item4, 23.17) self.assertIs(type(item5), bt2._StringValueConst) - self.assertEqual(item5, 'yes') + self.assertEqual(item5, "yes") def test_getitem_wrong_key(self): with self.assertRaises(KeyError): - self._def['kilojoule'] + self._def["kilojoule"] -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/bindings/python/bt2/utils.py b/tests/bindings/python/bt2/utils.py index a15e777b..410bb78c 100644 --- a/tests/bindings/python/bt2/utils.py +++ b/tests/bindings/python/bt2/utils.py @@ -22,7 +22,7 @@ def run_in_component_init(func): g = bt2.Graph() res_bound = None - g.add_component(MySink, 'comp') + g.add_component(MySink, "comp") # We deliberately use a different variable for returning the result than # the variable bound to the MySink.__init__ context and delete res_bound. @@ -58,47 +58,47 @@ def _get_all_message_types(with_packet=True): self._at = 0 self._msgs = [ self._create_stream_beginning_message( - self_output_port.user_data['stream'] + self_output_port.user_data["stream"] ) ] if with_packet: - assert self_output_port.user_data['packet'] + assert self_output_port.user_data["packet"] self._msgs.append( self._create_packet_beginning_message( - self_output_port.user_data['packet'] + self_output_port.user_data["packet"] ) ) default_clock_snapshot = 789 if with_packet: - assert self_output_port.user_data['packet'] - ev_parent = self_output_port.user_data['packet'] + assert self_output_port.user_data["packet"] + ev_parent = self_output_port.user_data["packet"] else: - assert self_output_port.user_data['stream'] - ev_parent = self_output_port.user_data['stream'] + assert self_output_port.user_data["stream"] + ev_parent = self_output_port.user_data["stream"] msg = self._create_event_message( - self_output_port.user_data['event_class'], + self_output_port.user_data["event_class"], ev_parent, default_clock_snapshot, ) - msg.event.payload_field['giraffe'] = 1 - msg.event.specific_context_field['ant'] = -1 - msg.event.common_context_field['cpu_id'] = 1 + msg.event.payload_field["giraffe"] = 1 + msg.event.specific_context_field["ant"] = -1 + msg.event.common_context_field["cpu_id"] = 1 self._msgs.append(msg) if with_packet: self._msgs.append( self._create_packet_end_message( - self_output_port.user_data['packet'] + self_output_port.user_data["packet"] ) ) self._msgs.append( - self._create_stream_end_message(self_output_port.user_data['stream']) + self._create_stream_end_message(self_output_port.user_data["stream"]) ) _msgs = self._msgs @@ -118,14 +118,14 @@ def _get_all_message_types(with_packet=True): # event common context (stream-class-defined) cc = tc.create_structure_field_class() - cc += [('cpu_id', tc.create_signed_integer_field_class(8))] + cc += [("cpu_id", tc.create_signed_integer_field_class(8))] # packet context (stream-class-defined) pc = None if with_packet: pc = tc.create_structure_field_class() - pc += [('something', tc.create_unsigned_integer_field_class(8))] + pc += [("something", tc.create_unsigned_integer_field_class(8))] stream_class = tc.create_stream_class( default_clock_class=clock_class, @@ -136,39 +136,39 @@ def _get_all_message_types(with_packet=True): # specific context (event-class-defined) sc = tc.create_structure_field_class() - sc += [('ant', tc.create_signed_integer_field_class(16))] + sc += [("ant", tc.create_signed_integer_field_class(16))] # event payload ep = tc.create_structure_field_class() - ep += [('giraffe', tc.create_signed_integer_field_class(32))] + ep += [("giraffe", tc.create_signed_integer_field_class(32))] event_class = stream_class.create_event_class( - name='garou', specific_context_field_class=sc, payload_field_class=ep + name="garou", specific_context_field_class=sc, payload_field_class=ep ) - trace = tc(environment={'patate': 12}) - stream = trace.create_stream(stream_class, user_attributes={'salut': 23}) + trace = tc(environment={"patate": 12}) + stream = trace.create_stream(stream_class, user_attributes={"salut": 23}) if with_packet: packet = stream.create_packet() - packet.context_field['something'] = 154 + packet.context_field["something"] = 154 else: packet = None self._add_output_port( - 'out', + "out", { - 'tc': tc, - 'stream': stream, - 'event_class': event_class, - 'trace': trace, - 'packet': packet, + "tc": tc, + "stream": stream, + "event_class": event_class, + "trace": trace, + "packet": packet, }, ) _graph = bt2.Graph() - _src_comp = _graph.add_component(MySrc, 'my_source') - _msg_iter = TestOutputPortMessageIterator(_graph, _src_comp.output_ports['out']) + _src_comp = _graph.add_component(MySrc, "my_source") + _msg_iter = TestOutputPortMessageIterator(_graph, _src_comp.output_ports["out"]) const_msgs = list(_msg_iter) @@ -241,10 +241,10 @@ class TestProxySink(bt2._UserSinkComponent): def __init__(self, config, params, msg_list): assert msg_list is not None self._msg_list = msg_list - self._add_input_port('in') + self._add_input_port("in") def _user_graph_is_configured(self): - self._msg_iter = self._create_message_iterator(self._input_ports['in']) + self._msg_iter = self._create_message_iterator(self._input_ports["in"]) def _user_consume(self): assert self._msg_list[0] is None @@ -265,8 +265,8 @@ class TestOutputPortMessageIterator(collections.abc.Iterator): def __init__(self, graph, output_port): self._graph = graph self._msg_list = [None] - sink = graph.add_component(TestProxySink, 'test-proxy-sink', obj=self._msg_list) - graph.connect_ports(output_port, sink.input_ports['in']) + sink = graph.add_component(TestProxySink, "test-proxy-sink", obj=self._msg_list) + graph.connect_ports(output_port, sink.input_ports["in"]) def __next__(self): assert self._msg_list[0] is None @@ -282,7 +282,7 @@ class TestOutputPortMessageIterator(collections.abc.Iterator): # The field is part of a dummy stream, itself part of a dummy trace created # from trace class `tc`. def create_const_field(tc, field_class, field_value_setter_fn): - field_name = 'const field' + field_name = "const field" class MyIter(bt2._UserMessageIterator): def __init__(self, config, self_port_output): @@ -312,11 +312,11 @@ def create_const_field(tc, field_class, field_value_setter_fn): class MySrc(bt2._UserSourceComponent, message_iterator_class=MyIter): def __init__(self, config, params, obj): - self._add_output_port('out', params) + self._add_output_port("out", params) graph = bt2.Graph() - src_comp = graph.add_component(MySrc, 'my_source', None) - msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports['out']) + src_comp = graph.add_component(MySrc, "my_source", None) + msg_iter = TestOutputPortMessageIterator(graph, src_comp.output_ports["out"]) # Ignore first message, stream beginning _ = next(msg_iter) @@ -354,11 +354,11 @@ def run_in_message_iterator_next(create_stream_class_func, msg_iter_next_func): cc = self._create_clock_class() sc = create_stream_class_func(tc, cc) - self._add_output_port('out', (tc, sc)) + self._add_output_port("out", (tc, sc)) class MySink(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._input_port = self._add_input_port('in') + self._input_port = self._add_input_port("in") def _user_graph_is_configured(self): self._input_iter = self._create_message_iterator(self._input_port) @@ -368,9 +368,9 @@ def run_in_message_iterator_next(create_stream_class_func, msg_iter_next_func): graph = bt2.Graph() res_bound = None - src = graph.add_component(MySrc, 'ze source') - snk = graph.add_component(MySink, 'ze sink') - graph.connect_ports(src.output_ports['out'], snk.input_ports['in']) + src = graph.add_component(MySrc, "ze source") + snk = graph.add_component(MySink, "ze sink") + graph.connect_ports(src.output_ports["out"], snk.input_ports["in"]) graph.run() # We deliberately use a different variable for returning the result than diff --git a/tests/data/auto-source-discovery/grouping/bt_plugin_test.py b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py index c885040c..208f5381 100644 --- a/tests/data/auto-source-discovery/grouping/bt_plugin_test.py +++ b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py @@ -14,8 +14,8 @@ import os class TestIter(bt2._UserMessageIterator): def __init__(self, config, output_port): - inputs = output_port.user_data['inputs'] - sc = output_port.user_data['sc'] + inputs = output_port.user_data["inputs"] + sc = output_port.user_data["sc"] tc = sc.trace_class t = tc() s = t.create_stream(sc, name=self._make_stream_name(inputs)) @@ -29,8 +29,8 @@ class TestIter(bt2._UserMessageIterator): comp_cls_name = self._component.__class__.__name__ return ( comp_cls_name - + ': ' - + ', '.join(sorted([os.path.basename(str(x)) for x in inputs])) + + ": " + + ", ".join(sorted([os.path.basename(str(x)) for x in inputs])) ) def __next__(self): @@ -45,7 +45,7 @@ class Base: tc = self._create_trace_class() sc = tc.create_stream_class() - self._add_output_port('out', {'inputs': params['inputs'], 'sc': sc}) + self._add_output_port("out", {"inputs": params["inputs"], "sc": sc}) @bt2.plugin_component_class @@ -62,17 +62,17 @@ class TestSourceExt(Base, bt2._UserSourceComponent, message_iterator_class=TestI @staticmethod def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': - if params['type'] == 'file': - name = os.path.basename(str(params['input'])) - - if name.startswith('aaa'): - return {'weight': 1, 'group': 'aaa'} - elif name.startswith('bbb'): - return {'weight': 0.5, 'group': 'bbb'} - elif name.startswith('ccc'): + if obj == "babeltrace.support-info": + if params["type"] == "file": + name = os.path.basename(str(params["input"])) + + if name.startswith("aaa"): + return {"weight": 1, "group": "aaa"} + elif name.startswith("bbb"): + return {"weight": 0.5, "group": "bbb"} + elif name.startswith("ccc"): # Try two different ways of returning 1 (an int and a float). - if name[3] == '1': + if name[3] == "1": return 1 else: return 1.0 @@ -95,10 +95,10 @@ class TestSourceSomeDir( @staticmethod def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': - if params['type'] == 'directory': - name = os.path.basename(str(params['input'])) - return 1 if name == 'some-dir' else 0 + if obj == "babeltrace.support-info": + if params["type"] == "directory": + name = os.path.basename(str(params["input"])) + return 1 if name == "some-dir" else 0 else: return 0 else: @@ -114,10 +114,10 @@ class TestSourceABCDE(Base, bt2._UserSourceComponent, message_iterator_class=Tes @staticmethod def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': + if obj == "babeltrace.support-info": return ( 1.0 - if params['type'] == 'string' and params['input'] == 'ABCDE' + if params["type"] == "string" and params["input"] == "ABCDE" else 0.0 ) else: diff --git a/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py index 4464cc6b..91d0c74c 100644 --- a/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py +++ b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py @@ -18,24 +18,24 @@ import os class TestIter(bt2._UserMessageIterator): def __init__(self, config, output_port): - params = output_port.user_data['params'] - obj = output_port.user_data['obj'] + params = output_port.user_data["params"] + obj = output_port.user_data["obj"] comp_cls_name = self._component.__class__.__name__ - if params['what'] == 'test-params': - items = sorted([str(x) for x in params.items() if x[0].startswith('test-')]) - stream_name = '{}: {}'.format(comp_cls_name, ', '.join(items)) - elif params['what'] == 'log-level': + if params["what"] == "test-params": + items = sorted([str(x) for x in params.items() if x[0].startswith("test-")]) + stream_name = "{}: {}".format(comp_cls_name, ", ".join(items)) + elif params["what"] == "log-level": log_level = self._component.logging_level - stream_name = '{}: {}'.format(comp_cls_name, log_level) - elif params['what'] == 'python-obj': + stream_name = "{}: {}".format(comp_cls_name, log_level) + elif params["what"] == "python-obj": assert type(obj) == str or obj is None - stream_name = '{}: {}'.format(comp_cls_name, obj) + stream_name = "{}: {}".format(comp_cls_name, obj) else: assert False - sc = output_port.user_data['sc'] + sc = output_port.user_data["sc"] tc = sc.trace_class t = tc() s = t.create_stream(sc, name=stream_name) @@ -57,7 +57,7 @@ class Base: tc = self._create_trace_class() sc = tc.create_stream_class() - self._add_output_port('out', {'params': params, 'obj': obj, 'sc': sc}) + self._add_output_port("out", {"params": params, "obj": obj, "sc": sc}) @bt2.plugin_component_class @@ -69,14 +69,14 @@ class TestSourceA(Base, bt2._UserSourceComponent, message_iterator_class=TestIte def _user_query(priv_query_exec, obj, params, method_obj): # Match files starting with 'aaa'. - if obj == 'babeltrace.support-info': - if params['type'] != 'file': + if obj == "babeltrace.support-info": + if params["type"] != "file": return 0 - name = os.path.basename(str(params['input'])) + name = os.path.basename(str(params["input"])) - if name.startswith('aaa'): - return {'weight': 1, 'group': 'aaa'} + if name.startswith("aaa"): + return {"weight": 1, "group": "aaa"} else: return 0 else: @@ -92,14 +92,14 @@ class TestSourceB(Base, bt2._UserSourceComponent, message_iterator_class=TestIte def _user_query(priv_query_exec, obj, params, method_obj): # Match files starting with 'bbb'. - if obj == 'babeltrace.support-info': - if params['type'] != 'file': + if obj == "babeltrace.support-info": + if params["type"] != "file": return 0 - name = os.path.basename(str(params['input'])) + name = os.path.basename(str(params["input"])) - if name.startswith('bbb'): - return {'weight': 1, 'group': 'bbb'} + if name.startswith("bbb"): + return {"weight": 1, "group": "bbb"} else: return 0 else: diff --git a/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py b/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py index 9451b57f..d651e251 100644 --- a/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py +++ b/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py @@ -13,7 +13,7 @@ bt2.register_plugin(__name__, "test_exit_status") class StatusIter(bt2._UserMessageIterator): def __init__(self, config, output_port): - self.case = output_port.user_data['case'] + self.case = output_port.user_data["case"] def __next__(self): if self.case == "STOP": @@ -30,7 +30,7 @@ class StatusIter(bt2._UserMessageIterator): time.sleep(0.1) raise Exception( - '{} was not interrupted after {} seconds'.format( + "{} was not interrupted after {} seconds".format( self.__class__.__name__, timeout_s ) ) @@ -44,4 +44,4 @@ class StatusIter(bt2._UserMessageIterator): @bt2.plugin_component_class class StatusSrc(bt2._UserSourceComponent, message_iterator_class=StatusIter): def __init__(self, config, params, obj): - self._add_output_port("out", {'case': params['case']}) + self._add_output_port("out", {"case": params["case"]}) diff --git a/tests/data/cli/list-plugins/bt_plugin_list_plugins.py b/tests/data/cli/list-plugins/bt_plugin_list_plugins.py index d65df2ae..e6d04e0f 100644 --- a/tests/data/cli/list-plugins/bt_plugin_list_plugins.py +++ b/tests/data/cli/list-plugins/bt_plugin_list_plugins.py @@ -29,8 +29,8 @@ class ThisIsASink(bt2._UserSinkComponent): bt2.register_plugin( __name__, "this-is-a-plugin", - version=(1, 2, 3, 'bob'), - description='A plugin', - author='Jorge Mario Bergoglio', - license='The license', + version=(1, 2, 3, "bob"), + description="A plugin", + author="Jorge Mario Bergoglio", + license="The license", ) diff --git a/tests/data/cli/params/bt_plugin_params.py b/tests/data/cli/params/bt_plugin_params.py index e900fb98..dfa7cfdf 100644 --- a/tests/data/cli/params/bt_plugin_params.py +++ b/tests/data/cli/params/bt_plugin_params.py @@ -10,7 +10,7 @@ from cli_params_to_string import to_string @bt2.plugin_component_class class SinkThatPrintsParams(bt2._UserSinkComponent): def __init__(self, config, params, obj): - self._add_input_port('in') + self._add_input_port("in") print(to_string(params)) def _user_consume(self): diff --git a/tests/data/cli/query/bt_plugin_query.py b/tests/data/cli/query/bt_plugin_query.py index ea50692d..b4197755 100644 --- a/tests/data/cli/query/bt_plugin_query.py +++ b/tests/data/cli/query/bt_plugin_query.py @@ -13,10 +13,10 @@ class SourceWithQueryThatPrintsParams( ): @classmethod def _user_query(cls, executor, obj, params, method_obj): - if obj == 'please-fail': - raise ValueError('catastrophic failure') + if obj == "please-fail": + raise ValueError("catastrophic failure") - return obj + ':' + to_string(params) + return obj + ":" + to_string(params) bt2.register_plugin(__name__, "query") diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py b/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py index 72532b48..cc9bc53b 100644 --- a/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py +++ b/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py @@ -29,20 +29,20 @@ class CompleteIter(bt2._UserMessageIterator): ev.event.payload_field["uint32"] = 121 ev.event.payload_field["uint61"] = 299792458 ev.event.payload_field["uint5_oct"] = 29 - ev.event.payload_field["struct"]['str'] = "Rotisserie St-Hubert" - ev.event.payload_field["struct"]['option_real'] = math.pi + ev.event.payload_field["struct"]["str"] = "Rotisserie St-Hubert" + ev.event.payload_field["struct"]["option_real"] = math.pi ev.event.payload_field["string"] = "🎉" ev.event.payload_field["dyn_array"] = [1.2, 2 / 3, 42.3, math.pi] ev.event.payload_field["dyn_array_len"] = 4 ev.event.payload_field["dyn_array_with_len"] = [5.2, 5 / 3, 42.5, math.pi * 12] - ev.event.payload_field["sta_array"] = ['🕰', '🦴', ' 🎍'] + ev.event.payload_field["sta_array"] = ["🕰", "🦴", " 🎍"] ev.event.payload_field["option_none"] ev.event.payload_field["option_some"] = "NORMANDIN" ev.event.payload_field["option_bool_selector"] = True ev.event.payload_field["option_bool"] = "Mike's" ev.event.payload_field["option_int_selector"] = 1 ev.event.payload_field["option_int"] = "Barbies resto bar grill" - ev.event.payload_field['variant'].selected_option_index = 0 + ev.event.payload_field["variant"].selected_option_index = 0 ev.event.payload_field["variant"] = "Couche-Tard" self._msgs = [ @@ -72,14 +72,14 @@ class CompleteSrc(bt2._UserSourceComponent, message_iterator_class=CompleteIter) option_some_fc = tc.create_string_field_class() variant_fc = tc.create_variant_field_class() variant_fc.append_option( - name='var_str', field_class=tc.create_string_field_class() + name="var_str", field_class=tc.create_string_field_class() ) option_none_fc = tc.create_double_precision_real_field_class() struct_fc = tc.create_structure_field_class() struct_option_fc = tc.create_double_precision_real_field_class() - struct_fc.append_member('str', tc.create_string_field_class()) + struct_fc.append_member("str", tc.create_string_field_class()) struct_fc.append_member( - 'option_real', + "option_real", tc.create_option_without_selector_field_class(struct_option_fc), ) option_bool_selector_fc = tc.create_bool_field_class() diff --git a/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py b/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py index bc447b43..8ac1f1b7 100644 --- a/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py +++ b/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py @@ -25,7 +25,7 @@ class TheSourceOfConfusion( bt2._UserSourceComponent, message_iterator_class=TheIteratorOfConfusion ): def __init__(self, config, params, obj): - test_name = str(params['test-name']) + test_name = str(params["test-name"]) TEST_CASES[test_name].source_setup(self, test_name) @@ -37,11 +37,11 @@ class DiffTraceName: tc2 = src._create_trace_class() cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - trace_name1 = 'rouyn' - trace_name2 = 'noranda' + trace_name1 = "rouyn" + trace_name2 = "noranda" - src._add_output_port('out1', (test_name, 1, tc1, cc1, trace_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, trace_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, trace_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, trace_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, trace_name = params @@ -64,11 +64,11 @@ class DiffStreamName: tc2 = src._create_trace_class() cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - stream_name1 = 'port-daniel' - stream_name2 = 'gascon' + stream_name1 = "port-daniel" + stream_name2 = "gascon" - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_name = params @@ -94,8 +94,8 @@ class DiffStreamId: stream_id1 = 18 stream_id2 = 23 - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_id1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_id2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_id1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_id2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_id = params @@ -121,8 +121,8 @@ class DiffStreamNoName: stream_name1 = "one" stream_name2 = None - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_no_name = params @@ -148,8 +148,8 @@ class DiffStreamClassId: stream_class_id1 = 18 stream_class_id2 = 23 - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_id1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_id2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_class_id1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_class_id2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_class_id = params @@ -174,11 +174,11 @@ class DiffStreamClassName: tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - stream_class_name1 = 'one' - stream_class_name2 = 'two' + stream_class_name1 = "one" + stream_class_name2 = "two" - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_class_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_class_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_class_name = params @@ -204,11 +204,11 @@ class DiffStreamClassNoName: tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - stream_class_name1 = 'one' + stream_class_name1 = "one" stream_class_name2 = None - src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, stream_class_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, stream_class_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, stream_class_name = params @@ -236,9 +236,9 @@ class BasicTimestampOrdering: timestamp2 = 120 timestamp3 = 4 - src._add_output_port('out1', (test_name, 1, tc, cc, timestamp1)) - src._add_output_port('out2', (test_name, 2, tc, cc, timestamp2)) - src._add_output_port('out3', (test_name, 3, tc, cc, timestamp3)) + src._add_output_port("out1", (test_name, 1, tc, cc, timestamp1)) + src._add_output_port("out2", (test_name, 2, tc, cc, timestamp2)) + src._add_output_port("out3", (test_name, 3, tc, cc, timestamp3)) def create_msgs(msg_iter, params): iter_id, tc, cc, timestamp = params @@ -260,15 +260,15 @@ class MultiIterOrdering: tc4 = src._create_trace_class(assigns_automatic_stream_class_id=False) cc = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - src._add_output_port('out1', (test_name, 1, tc1, cc)) - src._add_output_port('out2', (test_name, 2, tc2, cc)) - src._add_output_port('out3', (test_name, 3, tc3, cc)) - src._add_output_port('out4', (test_name, 4, tc4, cc)) + src._add_output_port("out1", (test_name, 1, tc1, cc)) + src._add_output_port("out2", (test_name, 2, tc2, cc)) + src._add_output_port("out3", (test_name, 3, tc3, cc)) + src._add_output_port("out4", (test_name, 4, tc4, cc)) def create_msgs(msg_iter, params): iter_id, tc, cc = params - trace_hello = tc(name='hello') - trace_meow = tc(name='meow') + trace_hello = tc(name="hello") + trace_meow = tc(name="meow") # Craft list of messages for each iterator so that the last messages of # each iterator are all sharing the same timestamp. @@ -280,7 +280,7 @@ class MultiIterOrdering: id=0, default_clock_class=cc, assigns_automatic_stream_id=False ) sc_0_stream_1 = trace_hello.create_stream(stream_class0, id=1) - event_class = stream_class0.create_event_class(name='saumon atlantique') + event_class = stream_class0.create_event_class(name="saumon atlantique") msg_iter._msgs = [ msg_iter._create_stream_beginning_message(sc_0_stream_1, 0), @@ -331,7 +331,7 @@ class MultiIterOrdering: sc_1_stream_1 = trace_meow.create_stream(stream_class1, id=1) - event_class = stream_class1.create_event_class(name='bar rayé') + event_class = stream_class1.create_event_class(name="bar rayé") msg_iter._msgs = [ msg_iter._create_stream_beginning_message(sc_1_stream_1, 3), msg_iter._create_event_message( @@ -348,11 +348,11 @@ class DiffEventClassName: tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) - event_class_name1 = 'Hull' - event_class_name2 = 'Gatineau' + event_class_name1 = "Hull" + event_class_name2 = "Gatineau" - src._add_output_port('out1', (test_name, 1, tc1, cc1, event_class_name1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, event_class_name2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, event_class_name1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, event_class_name2)) def create_msgs(msg_iter, params): iter_id, tc, cc, event_class_name = params @@ -387,8 +387,8 @@ class DiffEventClassId: event_class_id1 = 1 event_class_id2 = 2 - src._add_output_port('out1', (test_name, 1, tc1, cc1, event_class_id1)) - src._add_output_port('out2', (test_name, 2, tc2, cc2, event_class_id2)) + src._add_output_port("out1", (test_name, 1, tc1, cc1, event_class_id1)) + src._add_output_port("out2", (test_name, 2, tc2, cc2, event_class_id2)) def create_msgs(msg_iter, params): iter_id, tc, cc, event_class_id = params @@ -416,14 +416,14 @@ class DiffEventClassId: class DiffInactivityMsgCs: def source_setup(src, test_name): cc1 = src._create_clock_class( - frequency=1, name='La Baie', offset=bt2.ClockClassOffset(0) + frequency=1, name="La Baie", offset=bt2.ClockClassOffset(0) ) cc2 = src._create_clock_class( - frequency=1, name='Chicoutimi', offset=bt2.ClockClassOffset(0) + frequency=1, name="Chicoutimi", offset=bt2.ClockClassOffset(0) ) - src._add_output_port('out1', (test_name, cc1)) - src._add_output_port('out2', (test_name, cc2)) + src._add_output_port("out1", (test_name, cc1)) + src._add_output_port("out2", (test_name, cc2)) def create_msgs(msg_iter, params): (cc,) = params @@ -432,18 +432,18 @@ class DiffInactivityMsgCs: TEST_CASES = { - 'diff_trace_name': DiffTraceName, - 'diff_event_class_name': DiffEventClassName, - 'diff_event_class_id': DiffEventClassId, - 'diff_stream_name': DiffStreamName, - 'diff_stream_no_name': DiffStreamNoName, - 'diff_stream_id': DiffStreamId, - 'diff_stream_class_id': DiffStreamClassId, - 'diff_stream_class_name': DiffStreamClassName, - 'diff_stream_class_no_name': DiffStreamClassNoName, - 'diff_inactivity_msg_cs': DiffInactivityMsgCs, - 'basic_timestamp_ordering': BasicTimestampOrdering, - 'multi_iter_ordering': MultiIterOrdering, + "diff_trace_name": DiffTraceName, + "diff_event_class_name": DiffEventClassName, + "diff_event_class_id": DiffEventClassId, + "diff_stream_name": DiffStreamName, + "diff_stream_no_name": DiffStreamNoName, + "diff_stream_id": DiffStreamId, + "diff_stream_class_id": DiffStreamClassId, + "diff_stream_class_name": DiffStreamClassName, + "diff_stream_class_no_name": DiffStreamClassNoName, + "diff_inactivity_msg_cs": DiffInactivityMsgCs, + "basic_timestamp_ordering": BasicTimestampOrdering, + "multi_iter_ordering": MultiIterOrdering, } -bt2.register_plugin(__name__, 'test-muxer') +bt2.register_plugin(__name__, "test-muxer") diff --git a/tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py b/tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py index 8ce29f03..857fcc92 100644 --- a/tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py +++ b/tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py @@ -12,20 +12,20 @@ class TheIteratorOfAllEvil(bt2._UserMessageIterator): trace = tc() stream = trace.create_stream(sc) - if params['with-packet-msgs']: + if params["with-packet-msgs"]: packet = stream.create_packet() - if params['with-stream-msgs-cs']: + if params["with-stream-msgs-cs"]: sb_msg = self._create_stream_beginning_message(stream, 100) else: sb_msg = self._create_stream_beginning_message(stream) - parent = packet if params['with-packet-msgs'] else stream + parent = packet if params["with-packet-msgs"] else stream ev_msg1 = self._create_event_message(ec1, parent, 300) ev_msg2 = self._create_event_message(ec2, parent, 400) - if params['with-stream-msgs-cs']: + if params["with-stream-msgs-cs"]: se_msg = self._create_stream_end_message(stream, 1000) else: se_msg = self._create_stream_end_message(stream) @@ -34,13 +34,13 @@ class TheIteratorOfAllEvil(bt2._UserMessageIterator): self._msgs.append(sb_msg) - if params['with-packet-msgs']: + if params["with-packet-msgs"]: self._msgs.append(self._create_packet_beginning_message(packet, 200)) self._msgs.append(ev_msg1) self._msgs.append(ev_msg2) - if params['with-packet-msgs']: + if params["with-packet-msgs"]: self._msgs.append(self._create_packet_end_message(packet, 900)) self._msgs.append(se_msg) @@ -67,7 +67,7 @@ class TheSourceOfAllEvil( def __init__(self, config, params, obj): tc = self._create_trace_class() - with_packets = bool(params['with-packet-msgs']) + with_packets = bool(params["with-packet-msgs"]) # Use a clock class with an offset, so we can test with --begin or --end # smaller than this offset (in other words, a time that it's not @@ -79,9 +79,9 @@ class TheSourceOfAllEvil( packets_have_beginning_default_clock_snapshot=with_packets, packets_have_end_default_clock_snapshot=with_packets, ) - ec1 = sc.create_event_class(name='event 1') - ec2 = sc.create_event_class(name='event 2') - self._add_output_port('out', (tc, sc, ec1, ec2, params)) + ec1 = sc.create_event_class(name="event 1") + ec2 = sc.create_event_class(name="event 2") + self._add_output_port("out", (tc, sc, ec1, ec2, params)) -bt2.register_plugin(__name__, 'test-trimmer') +bt2.register_plugin(__name__, "test-trimmer") diff --git a/tests/data/plugins/sink.ctf.fs/assume-single-trace/bt_plugin_foo.py b/tests/data/plugins/sink.ctf.fs/assume-single-trace/bt_plugin_foo.py index 0dd2aed6..f4c09466 100644 --- a/tests/data/plugins/sink.ctf.fs/assume-single-trace/bt_plugin_foo.py +++ b/tests/data/plugins/sink.ctf.fs/assume-single-trace/bt_plugin_foo.py @@ -11,7 +11,7 @@ class TheSourceIterator(bt2._UserMessageIterator): tc, sc, ec = port.user_data trace = tc() - stream = trace.create_stream(sc, name='the-stream') + stream = trace.create_stream(sc, name="the-stream") self._msgs = [ self._create_stream_beginning_message(stream), @@ -31,8 +31,8 @@ class TheSource(bt2._UserSourceComponent, message_iterator_class=TheSourceIterat def __init__(self, config, params, obj): tc = self._create_trace_class() sc = tc.create_stream_class() - ec = sc.create_event_class(name='the-event') - self._add_output_port('out', user_data=(tc, sc, ec)) + ec = sc.create_event_class(name="the-event") + self._add_output_port("out", user_data=(tc, sc, ec)) bt2.register_plugin(__name__, "foo") diff --git a/tests/data/plugins/sink.ctf.fs/stream-names/bt_plugin_foo.py b/tests/data/plugins/sink.ctf.fs/stream-names/bt_plugin_foo.py index 107be40d..98930aa6 100644 --- a/tests/data/plugins/sink.ctf.fs/stream-names/bt_plugin_foo.py +++ b/tests/data/plugins/sink.ctf.fs/stream-names/bt_plugin_foo.py @@ -15,9 +15,9 @@ class TheSourceIterator(bt2._UserMessageIterator): # Make two streams with the same name, to verify the stream filenames # are de-duplicated properly. Make one with the name "metadata" to # verify the resulting data file is not named "metadata". - stream1 = trace.create_stream(sc, name='the-stream') - stream2 = trace.create_stream(sc, name='the-stream') - stream3 = trace.create_stream(sc, name='metadata') + stream1 = trace.create_stream(sc, name="the-stream") + stream2 = trace.create_stream(sc, name="the-stream") + stream3 = trace.create_stream(sc, name="metadata") self._msgs = [ self._create_stream_beginning_message(stream1), @@ -43,8 +43,8 @@ class TheSource(bt2._UserSourceComponent, message_iterator_class=TheSourceIterat def __init__(self, config, params, obj): tc = self._create_trace_class() sc = tc.create_stream_class() - ec = sc.create_event_class(name='the-event') - self._add_output_port('out', user_data=(tc, sc, ec)) + ec = sc.create_event_class(name="the-event") + self._add_output_port("out", user_data=(tc, sc, ec)) bt2.register_plugin(__name__, "foo") diff --git a/tests/data/plugins/sink.text.pretty/bt_plugin_pretty_test.py b/tests/data/plugins/sink.text.pretty/bt_plugin_pretty_test.py index c3a66f74..37b1fdab 100644 --- a/tests/data/plugins/sink.text.pretty/bt_plugin_pretty_test.py +++ b/tests/data/plugins/sink.text.pretty/bt_plugin_pretty_test.py @@ -9,7 +9,7 @@ class TheIteratorOfProblems(bt2._UserMessageIterator): tc, sc, ec1, params = port.user_data trace = tc() stream = trace.create_stream(sc) - event_value = params['value'] + event_value = params["value"] self._msgs = [] self._msgs.append(self._create_stream_beginning_message(stream)) @@ -43,25 +43,25 @@ class TheSourceOfProblems( def __init__(self, config, params, obj): tc = self._create_trace_class() - enum_values_str = params['enum-values'] + enum_values_str = params["enum-values"] sc = tc.create_stream_class() # Create the enumeration field with the values in parameter - if params['enum-signed']: + if params["enum-signed"]: enumfc = tc.create_signed_enumeration_field_class() else: enumfc = tc.create_unsigned_enumeration_field_class() - groups = str(enum_values_str).split(' ') + groups = str(enum_values_str).split(" ") mappings = {} range_set_type = ( bt2.SignedIntegerRangeSet - if params['enum-signed'] + if params["enum-signed"] else bt2.UnsignedIntegerRangeSet ) for group in groups: - label, low, high = group.split(',') + label, low, high = group.split(",") if label not in mappings.keys(): mappings[label] = range_set_type() @@ -73,11 +73,11 @@ class TheSourceOfProblems( # Create the struct field to contain the enum field class struct_fc = tc.create_structure_field_class() - struct_fc.append_member('enum_field', enumfc) + struct_fc.append_member("enum_field", enumfc) # Create an event class on this stream with the struct field - ec1 = sc.create_event_class(name='with_enum', payload_field_class=struct_fc) - self._add_output_port('out', (tc, sc, ec1, params)) + ec1 = sc.create_event_class(name="with_enum", payload_field_class=struct_fc) + self._add_output_port("out", (tc, sc, ec1, params)) -bt2.register_plugin(__name__, 'test-pretty') +bt2.register_plugin(__name__, "test-pretty") diff --git a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py index 0ffb9099..d0eb26d2 100644 --- a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py +++ b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py @@ -394,14 +394,14 @@ class _LttngLiveViewerDetachFromTracingSessionReply: # An LTTng live protocol codec can convert bytes to command objects and # reply objects to bytes. class _LttngLiveViewerProtocolCodec: - _COMMAND_HEADER_STRUCT_FMT = 'QII' + _COMMAND_HEADER_STRUCT_FMT = "QII" _COMMAND_HEADER_SIZE_BYTES = struct.calcsize(_COMMAND_HEADER_STRUCT_FMT) def __init__(self): pass def _unpack(self, fmt, data, offset=0): - fmt = '!' + fmt + fmt = "!" + fmt return struct.unpack_from(fmt, data, offset) def _unpack_payload(self, fmt, data): @@ -418,7 +418,7 @@ class _LttngLiveViewerProtocolCodec: self._COMMAND_HEADER_STRUCT_FMT, data ) logging.info( - 'Decoded command header: payload-size={}, cmd-type={}, version={}'.format( + "Decoded command header: payload-size={}, cmd-type={}, version={}".format( payload_size, cmd_type, version ) ) @@ -429,7 +429,7 @@ class _LttngLiveViewerProtocolCodec: if cmd_type == 1: viewer_session_id, major, minor, conn_type = self._unpack_payload( - 'QIII', data + "QIII", data ) return _LttngLiveViewerConnectCommand( version, viewer_session_id, major, minor @@ -437,46 +437,46 @@ class _LttngLiveViewerProtocolCodec: elif cmd_type == 2: return _LttngLiveViewerGetTracingSessionInfosCommand(version) elif cmd_type == 3: - tracing_session_id, offset, seek_type = self._unpack_payload('QQI', data) + tracing_session_id, offset, seek_type = self._unpack_payload("QQI", data) return _LttngLiveViewerAttachToTracingSessionCommand( version, tracing_session_id, offset, seek_type ) elif cmd_type == 4: - (stream_id,) = self._unpack_payload('Q', data) + (stream_id,) = self._unpack_payload("Q", data) return _LttngLiveViewerGetNextDataStreamIndexEntryCommand( version, stream_id ) elif cmd_type == 5: - stream_id, offset, req_length = self._unpack_payload('QQI', data) + stream_id, offset, req_length = self._unpack_payload("QQI", data) return _LttngLiveViewerGetDataStreamPacketDataCommand( version, stream_id, offset, req_length ) elif cmd_type == 6: - (stream_id,) = self._unpack_payload('Q', data) + (stream_id,) = self._unpack_payload("Q", data) return _LttngLiveViewerGetMetadataStreamDataCommand(version, stream_id) elif cmd_type == 7: - (tracing_session_id,) = self._unpack_payload('Q', data) + (tracing_session_id,) = self._unpack_payload("Q", data) return _LttngLiveViewerGetNewStreamInfosCommand(version, tracing_session_id) elif cmd_type == 8: return _LttngLiveViewerCreateViewerSessionCommand(version) elif cmd_type == 9: - (tracing_session_id,) = self._unpack_payload('Q', data) + (tracing_session_id,) = self._unpack_payload("Q", data) return _LttngLiveViewerDetachFromTracingSessionCommand( version, tracing_session_id ) else: - raise UnexpectedInput('Unknown command type {}'.format(cmd_type)) + raise UnexpectedInput("Unknown command type {}".format(cmd_type)) def _pack(self, fmt, *args): # Force network byte order - return struct.pack('!' + fmt, *args) + return struct.pack("!" + fmt, *args) def _encode_zero_padded_str(self, string, length): data = string.encode() - return data.ljust(length, b'\x00') + return data.ljust(length, b"\x00") def _encode_stream_info(self, info): - data = self._pack('QQI', info.id, info.trace_id, int(info.is_metadata)) + data = self._pack("QQI", info.id, info.trace_id, int(info.is_metadata)) data += self._encode_zero_padded_str(info.path, 4096) data += self._encode_zero_padded_str(info.channel_name, 255) return data @@ -495,14 +495,14 @@ class _LttngLiveViewerProtocolCodec: def encode(self, reply): if type(reply) is _LttngLiveViewerConnectReply: data = self._pack( - 'QIII', reply.viewer_session_id, reply.major, reply.minor, 2 + "QIII", reply.viewer_session_id, reply.major, reply.minor, 2 ) elif type(reply) is _LttngLiveViewerGetTracingSessionInfosReply: - data = self._pack('I', len(reply.tracing_session_infos)) + data = self._pack("I", len(reply.tracing_session_infos)) for info in reply.tracing_session_infos: data += self._pack( - 'QIII', + "QIII", info.tracing_session_id, info.live_timer_freq, info.client_count, @@ -511,12 +511,12 @@ class _LttngLiveViewerProtocolCodec: data += self._encode_zero_padded_str(info.hostname, 64) data += self._encode_zero_padded_str(info.name, 255) elif type(reply) is _LttngLiveViewerAttachToTracingSessionReply: - data = self._pack('II', reply.status, len(reply.stream_infos)) + data = self._pack("II", reply.status, len(reply.stream_infos)) for info in reply.stream_infos: data += self._encode_stream_info(info) elif type(reply) is _LttngLiveViewerGetNextDataStreamIndexEntryReply: - index_format = 'QQQQQQQII' + index_format = "QQQQQQQII" entry = reply.index_entry flags = self._get_has_new_stuff_flags( reply.has_new_metadata, reply.has_new_data_stream @@ -553,23 +553,23 @@ class _LttngLiveViewerProtocolCodec: flags = self._get_has_new_stuff_flags( reply.has_new_metadata, reply.has_new_data_stream ) - data = self._pack('III', reply.status, len(reply.data), flags) + data = self._pack("III", reply.status, len(reply.data), flags) data += reply.data elif type(reply) is _LttngLiveViewerGetMetadataStreamDataContentReply: - data = self._pack('QI', len(reply.data), reply.status) + data = self._pack("QI", len(reply.data), reply.status) data += reply.data elif type(reply) is _LttngLiveViewerGetNewStreamInfosReply: - data = self._pack('II', reply.status, len(reply.stream_infos)) + data = self._pack("II", reply.status, len(reply.stream_infos)) for info in reply.stream_infos: data += self._encode_stream_info(info) elif type(reply) is _LttngLiveViewerCreateViewerSessionReply: - data = self._pack('I', reply.status) + data = self._pack("I", reply.status) elif type(reply) is _LttngLiveViewerDetachFromTracingSessionReply: - data = self._pack('I', reply.status) + data = self._pack("I", reply.status) else: raise ValueError( - 'Unknown reply object with class `{}`'.format(reply.__class__.__name__) + "Unknown reply object with class `{}`".format(reply.__class__.__name__) ) return data @@ -680,9 +680,9 @@ class _LttngDataStreamIndex(collections.abc.Sequence): self._entries = [] assert os.path.isfile(self._path) - with open(self._path, 'rb') as f: + with open(self._path, "rb") as f: # Read header first - fmt = '>IIII' + fmt = ">IIII" size = struct.calcsize(fmt) data = f.read(size) assert len(data) == size @@ -692,7 +692,7 @@ class _LttngDataStreamIndex(collections.abc.Sequence): assert magic == 0xC1F1DCC1 # Read index entries - fmt = '>QQQQQQQ' + fmt = ">QQQQQQQ" size = struct.calcsize(fmt) while True: @@ -760,13 +760,13 @@ class _LttngDataStream: def __init__(self, path, beacons): self._path = path filename = os.path.basename(path) - match = re.match(r'(.*)_\d+', filename) + match = re.match(r"(.*)_\d+", filename) self._channel_name = match.group(1) trace_dir = os.path.dirname(path) - index_path = os.path.join(trace_dir, 'index', filename + '.idx') + index_path = os.path.join(trace_dir, "index", filename + ".idx") self._index = _LttngDataStreamIndex(index_path, beacons) assert os.path.isfile(path) - self._file = open(path, 'rb') + self._file = open(path, "rb") logging.info( 'Built data stream: path="{}", channel-name="{}"'.format( path, self._channel_name @@ -798,7 +798,7 @@ class _LttngMetadataStreamSection: else: self._data = data logging.info( - 'Built metadata stream section: ts={}, data-len={}'.format( + "Built metadata stream section: ts={}, data-len={}".format( self._timestamp, len(self._data) ) ) @@ -818,7 +818,7 @@ class _LttngMetadataStream: self._path = metadata_file_path self._sections = config_sections logging.info( - 'Built metadata stream: path={}, section-len={}'.format( + "Built metadata stream: path={}, section-len={}".format( self._path, len(self._sections) ) ) @@ -833,7 +833,7 @@ class _LttngMetadataStream: LttngMetadataConfigSection = namedtuple( - 'LttngMetadataConfigSection', ['line', 'timestamp', 'is_empty'] + "LttngMetadataConfigSection", ["line", "timestamp", "is_empty"] ) @@ -845,14 +845,14 @@ def _parse_metadata_sections_config(config_sections): last_line = 0 for config_section in config_sections: - if config_section == 'empty': + if config_section == "empty": # Found a empty section marker. Actually append the section at the # timestamp of the next concrete section. append_empty_section = True else: assert type(config_section) is dict - line = config_section.get('line') - ts = config_section.get('timestamp') + line = config_section.get("line") + ts = config_section.get("timestamp") # Sections' timestamps and lines must both be increasing. assert ts > last_timestamp @@ -877,7 +877,7 @@ def _split_metadata_sections(metadata_file_path, raw_config_sections): parsed_sections = _parse_metadata_sections_config(raw_config_sections) sections = [] - with open(metadata_file_path, 'r') as metadata_file: + with open(metadata_file_path, "r") as metadata_file: metadata_lines = [line for line in metadata_file] config_metadata_sections_idx = 0 @@ -891,7 +891,7 @@ def _split_metadata_sections(metadata_file_path, raw_config_sections): # If there are no more sections, simply append the line. if config_metadata_sections_idx + 1 >= len(parsed_sections): - curr_metadata_section += bytearray(line_content, 'utf8') + curr_metadata_section += bytearray(line_content, "utf8") continue next_section_line_number = parsed_sections[ @@ -915,7 +915,7 @@ def _split_metadata_sections(metadata_file_path, raw_config_sections): # Clear old content and append current line for the next section. curr_metadata_section.clear() - curr_metadata_section += bytearray(line_content, 'utf8') + curr_metadata_section += bytearray(line_content, "utf8") # Append any empty sections. while parsed_sections[config_metadata_sections_idx].is_empty: @@ -927,7 +927,7 @@ def _split_metadata_sections(metadata_file_path, raw_config_sections): config_metadata_sections_idx += 1 else: # Append line_content to the current metadata section. - curr_metadata_section += bytearray(line_content, 'utf8') + curr_metadata_section += bytearray(line_content, "utf8") # We iterated over all the lines of the metadata file. Close the current section. sections.append( @@ -958,10 +958,10 @@ class LttngTrace(collections.abc.Sequence): if not os.path.isfile(path): continue - if filename.startswith('.'): + if filename.startswith("."): continue - if filename == 'metadata': + if filename == "metadata": continue data_stream_paths.append(path) @@ -981,11 +981,11 @@ class LttngTrace(collections.abc.Sequence): ) def _create_metadata_stream(self, trace_dir, config_metadata_sections): - metadata_path = os.path.join(trace_dir, 'metadata') + metadata_path = os.path.join(trace_dir, "metadata") metadata_sections = [] if config_metadata_sections is None: - with open(metadata_path, 'rb') as metadata_file: + with open(metadata_path, "rb") as metadata_file: metadata_sections.append( _LttngMetadataStreamSection(0, metadata_file.read()) ) @@ -1134,7 +1134,7 @@ class _LttngLiveViewerSessionTracingSessionState: # Metadata stream -> stream info and metadata stream state info = _LttngLiveViewerStreamInfo( - stream_id, trace_id, True, trace.metadata_stream.path, 'metadata' + stream_id, trace_id, True, trace.metadata_stream.path, "metadata" ) self._stream_infos.append(info) self._ms_states[stream_id] = _LttngLiveViewerSessionMetadataStreamState( @@ -1246,20 +1246,20 @@ class _LttngLiveViewerSession: def _get_tracing_session_state(self, tracing_session_id): if tracing_session_id not in self._ts_states: raise UnexpectedInput( - 'Unknown tracing session ID {}'.format(tracing_session_id) + "Unknown tracing session ID {}".format(tracing_session_id) ) return self._ts_states[tracing_session_id] def _get_stream_state(self, stream_id): if stream_id not in self._stream_states: - UnexpectedInput('Unknown stream ID {}'.format(stream_id)) + UnexpectedInput("Unknown stream ID {}".format(stream_id)) return self._stream_states[stream_id] def handle_command(self, cmd): logging.info( - 'Handling command in viewer session: cmd-cls-name={}'.format( + "Handling command in viewer session: cmd-cls-name={}".format( cmd.__class__.__name__ ) ) @@ -1267,7 +1267,7 @@ class _LttngLiveViewerSession: if cmd_type not in self._command_handlers: raise UnexpectedInput( - 'Unexpected command: cmd-cls-name={}'.format(cmd.__class__.__name__) + "Unexpected command: cmd-cls-name={}".format(cmd.__class__.__name__) ) return self._command_handlers[cmd_type](cmd) @@ -1280,7 +1280,7 @@ class _LttngLiveViewerSession: if ts_state.is_attached: raise UnexpectedInput( - 'Cannot attach to tracing session `{}`: viewer is already attached'.format( + "Cannot attach to tracing session `{}`: viewer is already attached".format( info.name ) ) @@ -1299,7 +1299,7 @@ class _LttngLiveViewerSession: if not ts_state.is_attached: raise UnexpectedInput( - 'Cannot detach to tracing session `{}`: viewer is not attached'.format( + "Cannot detach to tracing session `{}`: viewer is not attached".format( info.name ) ) @@ -1316,7 +1316,7 @@ class _LttngLiveViewerSession: if type(stream_state) is not _LttngLiveViewerSessionDataStreamState: raise UnexpectedInput( - 'Stream with ID {} is not a data stream'.format(cmd.stream_id) + "Stream with ID {} is not a data stream".format(cmd.stream_id) ) if stream_state.cur_index_entry is None: @@ -1360,7 +1360,7 @@ class _LttngLiveViewerSession: if type(stream_state) is not _LttngLiveViewerSessionDataStreamState: raise UnexpectedInput( - 'Stream with ID {} is not a data stream'.format(cmd.stream_id) + "Stream with ID {} is not a data stream".format(cmd.stream_id) ) if stream_state.tracing_session_state.has_new_metadata: @@ -1393,7 +1393,7 @@ class _LttngLiveViewerSession: is not _LttngLiveViewerSessionMetadataStreamState ): raise UnexpectedInput( - 'Stream with ID {} is not a metadata stream'.format(cmd.stream_id) + "Stream with ID {} is not a metadata stream".format(cmd.stream_id) ) if metadata_stream_state.is_sent: @@ -1461,13 +1461,13 @@ class LttngLiveServer: def __init__( self, port_filename, tracing_session_descriptors, max_query_data_response_size ): - logging.info('Server configuration:') + logging.info("Server configuration:") - logging.info(' Port file name: `{}`'.format(port_filename)) + logging.info(" Port file name: `{}`".format(port_filename)) if max_query_data_response_size is not None: logging.info( - ' Maximum response data query size: `{}`'.format( + " Maximum response data query size: `{}`".format( max_query_data_response_size ) ) @@ -1495,7 +1495,7 @@ class LttngLiveServer: self._codec = _LttngLiveViewerProtocolCodec() # Port 0: OS assigns an unused port - serv_addr = ('localhost', 0) + serv_addr = ("localhost", 0) self._sock.bind(serv_addr) self._write_port_to_file(port_filename) @@ -1503,7 +1503,7 @@ class LttngLiveServer: self._listen() finally: self._sock.close() - logging.info('Closed connection and socket.') + logging.info("Closed connection and socket.") @property def _server_port(self): @@ -1513,33 +1513,33 @@ class LttngLiveServer: data = bytes() while True: - logging.info('Waiting for viewer command.') + logging.info("Waiting for viewer command.") buf = self._conn.recv(128) if not buf: - logging.info('Client closed connection.') + logging.info("Client closed connection.") if data: raise UnexpectedInput( - 'Client closed connection after having sent {} command bytes.'.format( + "Client closed connection after having sent {} command bytes.".format( len(data) ) ) return - logging.info('Received data from viewer: length={}'.format(len(buf))) + logging.info("Received data from viewer: length={}".format(len(buf))) data += buf try: cmd = self._codec.decode(data) except struct.error as exc: - raise UnexpectedInput('Malformed command: {}'.format(exc)) from exc + raise UnexpectedInput("Malformed command: {}".format(exc)) from exc if cmd is not None: logging.info( - 'Received command from viewer: cmd-cls-name={}'.format( + "Received command from viewer: cmd-cls-name={}".format( cmd.__class__.__name__ ) ) @@ -1548,7 +1548,7 @@ class LttngLiveServer: def _send_reply(self, reply): data = self._codec.encode(reply) logging.info( - 'Sending reply to viewer: reply-cls-name={}, length={}'.format( + "Sending reply to viewer: reply-cls-name={}, length={}".format( reply.__class__.__name__, len(data) ) ) @@ -1567,7 +1567,7 @@ class LttngLiveServer: # Create viewer session (arbitrary ID 23) logging.info( - 'LTTng live viewer connected: version={}.{}'.format(cmd.major, cmd.minor) + "LTTng live viewer connected: version={}.{}".format(cmd.major, cmd.minor) ) viewer_session = _LttngLiveViewerSession( 23, self._ts_descriptors, self._max_query_data_response_size @@ -1590,13 +1590,13 @@ class LttngLiveServer: self._send_reply(viewer_session.handle_command(cmd)) def _listen(self): - logging.info('Listening: port={}'.format(self._server_port)) + logging.info("Listening: port={}".format(self._server_port)) # Backlog must be present for Python version < 3.5. # 128 is an arbitrary number since we expect only 1 connection anyway. self._sock.listen(128) self._conn, viewer_addr = self._sock.accept() logging.info( - 'Accepted viewer: addr={}:{}'.format(viewer_addr[0], viewer_addr[1]) + "Accepted viewer: addr={}:{}".format(viewer_addr[0], viewer_addr[1]) ) try: @@ -1606,8 +1606,8 @@ class LttngLiveServer: def _write_port_to_file(self, port_filename): # Write the port number to a temporary file. - with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_port_file: - print(self._server_port, end='', file=tmp_port_file) + with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp_port_file: + print(self._server_port, end="", file=tmp_port_file) # Rename temporary file to real file os.replace(tmp_port_file.name, port_filename) @@ -1628,7 +1628,7 @@ class LttngTracingSessionDescriptor: ): for trace in traces: if name not in trace.path: - fmt = 'Tracing session name must be part of every trace path (`{}` not found in `{}`)' + fmt = "Tracing session name must be part of every trace path (`{}` not found in `{}`)" raise ValueError(fmt.format(name, trace.path)) self._traces = traces @@ -1680,23 +1680,23 @@ def _session_descriptors_from_path(sessions_filename, trace_path_prefix): # ] # } # ] - with open(sessions_filename, 'r') as sessions_file: + with open(sessions_filename, "r") as sessions_file: params = json.load(sessions_file) sessions = [] for session in params: - name = session['name'] - tracing_session_id = session['id'] - hostname = session['hostname'] - live_timer_freq = session['live-timer-freq'] - client_count = session['client-count'] + name = session["name"] + tracing_session_id = session["id"] + hostname = session["hostname"] + live_timer_freq = session["live-timer-freq"] + client_count = session["client-count"] traces = [] - for trace in session['traces']: - metadata_sections = trace.get('metadata-sections') - beacons = trace.get('beacons') - path = trace['path'] + for trace in session["traces"]: + metadata_sections = trace.get("metadata-sections") + beacons = trace.get("beacons") + path = trace["path"] if not os.path.isabs(path): path = os.path.join(trace_path_prefix, path) @@ -1718,54 +1718,54 @@ def _session_descriptors_from_path(sessions_filename, trace_path_prefix): def _loglevel_parser(string): - loglevels = {'info': logging.INFO, 'warning': logging.WARNING} + loglevels = {"info": logging.INFO, "warning": logging.WARNING} if string not in loglevels: msg = "{} is not a valid loglevel".format(string) raise argparse.ArgumentTypeError(msg) return loglevels[string] -if __name__ == '__main__': - logging.basicConfig(format='# %(asctime)-25s%(message)s') +if __name__ == "__main__": + logging.basicConfig(format="# %(asctime)-25s%(message)s") parser = argparse.ArgumentParser( - description='LTTng-live protocol mocker', add_help=False + description="LTTng-live protocol mocker", add_help=False ) parser.add_argument( - '--log-level', - default='warning', - choices=['info', 'warning'], - help='The loglevel to be used.', + "--log-level", + default="warning", + choices=["info", "warning"], + help="The loglevel to be used.", ) loglevel_namespace, remaining_args = parser.parse_known_args() logging.getLogger().setLevel(_loglevel_parser(loglevel_namespace.log_level)) parser.add_argument( - '--port-filename', - help='The final port file. This file is present when the server is ready to receive connection.', + "--port-filename", + help="The final port file. This file is present when the server is ready to receive connection.", required=True, ) parser.add_argument( - '--max-query-data-response-size', + "--max-query-data-response-size", type=int, - help='The maximum size of control data response in bytes', + help="The maximum size of control data response in bytes", ) parser.add_argument( - '--trace-path-prefix', + "--trace-path-prefix", type=str, - help='Prefix to prepend to the trace paths of session configurations', + help="Prefix to prepend to the trace paths of session configurations", ) parser.add_argument( - '--sessions-filename', + "--sessions-filename", type=str, - help='Path to a session configuration file', + help="Path to a session configuration file", ) parser.add_argument( - '-h', - '--help', - action='help', + "-h", + "--help", + action="help", default=argparse.SUPPRESS, - help='Show this help message and exit.', + help="Show this help message and exit.", ) args = parser.parse_args(args=remaining_args) diff --git a/tests/lib/conds/test.py b/tests/lib/conds/test.py index 0f39d2ac..d8e5fe2e 100644 --- a/tests/lib/conds/test.py +++ b/tests/lib/conds/test.py @@ -13,7 +13,7 @@ import json # the `conds-triggers` program's full path -_CONDS_TRIGGERS_PATH = os.environ['BT_TESTS_LIB_CONDS_TRIGGER_BIN'] +_CONDS_TRIGGERS_PATH = os.environ["BT_TESTS_LIB_CONDS_TRIGGER_BIN"] # test methods are added by _create_tests() @@ -45,14 +45,14 @@ class _CondTriggerDescriptor: class _PreCondTriggerDescriptor(_CondTriggerDescriptor): @property def type_str(self): - return 'pre' + return "pre" # postcondition trigger descriptor class _PostCondTriggerDescriptor(_CondTriggerDescriptor): @property def type_str(self): - return 'post' + return "post" # test method template for `LibPrePostCondsTestCase` @@ -63,7 +63,7 @@ def _test(self, descriptor): # # where `` is the descriptor's index. with subprocess.Popen( - [_CONDS_TRIGGERS_PATH, 'run', str(descriptor.index)], + [_CONDS_TRIGGERS_PATH, "run", str(descriptor.index)], stderr=subprocess.PIPE, universal_newlines=True, ) as proc: @@ -74,15 +74,15 @@ def _test(self, descriptor): # wait for program end and get standard error pipe's contents _, stderr = proc.communicate(timeout=timeout) except subprocess.TimeoutExpired: - self.fail('Process hanged for {} seconds'.format(timeout)) + self.fail("Process hanged for {} seconds".format(timeout)) return # assert that program aborted (only available on POSIX) - if os.name == 'posix': + if os.name == "posix": self.assertEqual(proc.returncode, -int(signal.SIGABRT)) # assert that the standard error text contains the condition ID - text = 'Condition ID: `{}`.'.format(descriptor.cond_id) + text = "Condition ID: `{}`.".format(descriptor.cond_id) self.assertIn(text, stderr) @@ -95,22 +95,22 @@ def _cond_trigger_descriptors_from_json(json_descr_array): for index, json_descr in enumerate(json_descr_array): # sanity check: check for duplicate - trigger_name = json_descr['name'] + trigger_name = json_descr["name"] if trigger_name in descriptor_names: raise ValueError( - 'Duplicate condition trigger name `{}`'.format(trigger_name) + "Duplicate condition trigger name `{}`".format(trigger_name) ) # condition ID - cond_id = json_descr['cond-id'] + cond_id = json_descr["cond-id"] - if cond_id.startswith('pre'): + if cond_id.startswith("pre"): cond_type = _PreCondTriggerDescriptor - elif cond_id.startswith('post'): + elif cond_id.startswith("post"): cond_type = _PostCondTriggerDescriptor else: - raise ValueError('Invalid condition ID `{}`'.format(cond_id)) + raise ValueError("Invalid condition ID `{}`".format(cond_id)) descriptors.append(cond_type(index, trigger_name, cond_id)) descriptor_names.add(trigger_name) @@ -123,7 +123,7 @@ def _create_tests(): # Execute `conds-triggers list` to get a JSON array of condition # trigger descriptors. json_descr_array = json.loads( - subprocess.check_output([_CONDS_TRIGGERS_PATH, 'list'], universal_newlines=True) + subprocess.check_output([_CONDS_TRIGGERS_PATH, "list"], universal_newlines=True) ) # get condition trigger descriptor objects from JSON @@ -132,8 +132,8 @@ def _create_tests(): # create test methods for descriptor in descriptors: # test method name - test_meth_name = 'test_{}'.format( - re.sub(r'[^a-zA-Z0-9_]', '_', descriptor.trigger_name) + test_meth_name = "test_{}".format( + re.sub(r"[^a-zA-Z0-9_]", "_", descriptor.trigger_name) ) # test method @@ -144,5 +144,5 @@ def _create_tests(): _create_tests() -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/plugins/sink.text.pretty/test_pretty.py b/tests/plugins/sink.text.pretty/test_pretty.py index 368afb6c..0e0cd218 100644 --- a/tests/plugins/sink.text.pretty/test_pretty.py +++ b/tests/plugins/sink.text.pretty/test_pretty.py @@ -12,7 +12,7 @@ class Test(unittest.TestCase): def test_unconnected_port_raises(self): graph = bt2.Graph() graph.add_component( - bt2.find_plugin('text').sink_component_classes['pretty'], 'snk' + bt2.find_plugin("text").sink_component_classes["pretty"], "snk" ) with self.assertRaisesRegex( @@ -21,5 +21,5 @@ class Test(unittest.TestCase): graph.run() -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/plugins/src.ctf.fs/query/test_query_support_info.py b/tests/plugins/src.ctf.fs/query/test_query_support_info.py index 72e604e8..d3ff276a 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_support_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_support_info.py @@ -9,55 +9,55 @@ import os session_rotation_trace_path = os.path.join( - os.environ['BT_CTF_TRACES_PATH'], 'succeed', 'session-rotation' + os.environ["BT_CTF_TRACES_PATH"], "succeed", "session-rotation" ) trace_10352_1 = os.path.join( session_rotation_trace_path, - 'archives', - '20190826T155748-0400-20190826T155751-0400-1', - 'ust', - 'pid', - 'hello-ust-10352-20190826-155748', + "archives", + "20190826T155748-0400-20190826T155751-0400-1", + "ust", + "pid", + "hello-ust-10352-20190826-155748", ) trace_10353_1 = os.path.join( session_rotation_trace_path, - 'archives', - '20190826T155748-0400-20190826T155751-0400-1', - 'ust', - 'pid', - 'hello-ust-10353-20190826-155748', + "archives", + "20190826T155748-0400-20190826T155751-0400-1", + "ust", + "pid", + "hello-ust-10353-20190826-155748", ) trace_10352_2 = os.path.join( session_rotation_trace_path, - 'archives', - '20190826T155750-0400-20190826T155753-0400-2', - 'ust', - 'pid', - 'hello-ust-10352-20190826-155748', + "archives", + "20190826T155750-0400-20190826T155753-0400-2", + "ust", + "pid", + "hello-ust-10352-20190826-155748", ) trace_10353_2 = os.path.join( session_rotation_trace_path, - 'archives', - '20190826T155750-0400-20190826T155753-0400-2', - 'ust', - 'pid', - 'hello-ust-10353-20190826-155748', + "archives", + "20190826T155750-0400-20190826T155753-0400-2", + "ust", + "pid", + "hello-ust-10353-20190826-155748", ) trace_10352_3 = os.path.join( session_rotation_trace_path, - '20190826T155753-0400-3', - 'ust', - 'pid', - 'hello-ust-10352-20190826-155748', + "20190826T155753-0400-3", + "ust", + "pid", + "hello-ust-10352-20190826-155748", ) trace_10353_3 = os.path.join( session_rotation_trace_path, - '20190826T155753-0400-3', - 'ust', - 'pid', - 'hello-ust-10353-20190826-155748', + "20190826T155753-0400-3", + "ust", + "pid", + "hello-ust-10353-20190826-155748", ) @@ -67,22 +67,22 @@ class QuerySupportInfoTestCase(unittest.TestCase): def do_one_query(input, expected_group): qe = bt2.QueryExecutor( - fs, 'babeltrace.support-info', {'input': input, 'type': 'directory'} + fs, "babeltrace.support-info", {"input": input, "type": "directory"} ) result = qe.query() - self.assertEqual(result['group'], expected_group) + self.assertEqual(result["group"], expected_group) - ctf = bt2.find_plugin('ctf') - fs = ctf.source_component_classes['fs'] + ctf = bt2.find_plugin("ctf") + fs = ctf.source_component_classes["fs"] - do_one_query(trace_10352_1, '21cdfa5e-9a64-490a-832c-53aca6c101ba') - do_one_query(trace_10352_2, '21cdfa5e-9a64-490a-832c-53aca6c101ba') - do_one_query(trace_10352_3, '21cdfa5e-9a64-490a-832c-53aca6c101ba') - do_one_query(trace_10353_1, '83656eb1-b131-40e7-9666-c04ae279b58c') - do_one_query(trace_10353_2, '83656eb1-b131-40e7-9666-c04ae279b58c') - do_one_query(trace_10353_3, '83656eb1-b131-40e7-9666-c04ae279b58c') + do_one_query(trace_10352_1, "21cdfa5e-9a64-490a-832c-53aca6c101ba") + do_one_query(trace_10352_2, "21cdfa5e-9a64-490a-832c-53aca6c101ba") + do_one_query(trace_10352_3, "21cdfa5e-9a64-490a-832c-53aca6c101ba") + do_one_query(trace_10353_1, "83656eb1-b131-40e7-9666-c04ae279b58c") + do_one_query(trace_10353_2, "83656eb1-b131-40e7-9666-c04ae279b58c") + do_one_query(trace_10353_3, "83656eb1-b131-40e7-9666-c04ae279b58c") -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py index eb8fd25c..ee906356 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py @@ -9,29 +9,29 @@ import os import re -test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH'] +test_ctf_traces_path = os.environ["BT_CTF_TRACES_PATH"] # Key to sort streams in a predictable order. def sort_predictably(stream): - return stream['port-name'] + return stream["port-name"] class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): def setUp(self): - ctf = bt2.find_plugin('ctf') - self._fs = ctf.source_component_classes['fs'] + ctf = bt2.find_plugin("ctf") + self._fs = ctf.source_component_classes["fs"] self._inputs = [ - os.path.join(test_ctf_traces_path, 'intersection', '3eventsintersect') + os.path.join(test_ctf_traces_path, "intersection", "3eventsintersect") ] def _check(self, trace, offset): - streams = sorted(trace['stream-infos'], key=sort_predictably) - self.assertEqual(streams[0]['range-ns']['begin'], 13515309000000000 + offset) - self.assertEqual(streams[0]['range-ns']['end'], 13515309000000100 + offset) - self.assertEqual(streams[1]['range-ns']['begin'], 13515309000000070 + offset) - self.assertEqual(streams[1]['range-ns']['end'], 13515309000000120 + offset) + streams = sorted(trace["stream-infos"], key=sort_predictably) + self.assertEqual(streams[0]["range-ns"]["begin"], 13515309000000000 + offset) + self.assertEqual(streams[0]["range-ns"]["end"], 13515309000000100 + offset) + self.assertEqual(streams[1]["range-ns"]["begin"], 13515309000000070 + offset) + self.assertEqual(streams[1]["range-ns"]["end"], 13515309000000120 + offset) # Test various cominations of the clock-class-offset-s and # clock-class-offset-ns parameters to babeltrace.trace-infos queries. @@ -40,7 +40,7 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): def test_no_clock_class_offset(self): res = bt2.QueryExecutor( - self._fs, 'babeltrace.trace-infos', {'inputs': self._inputs} + self._fs, "babeltrace.trace-infos", {"inputs": self._inputs} ).query() trace = res[0] self._check(trace, 0) @@ -50,8 +50,8 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): def test_clock_class_offset_s(self): res = bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-s': 2}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-s": 2}, ).query() trace = res[0] self._check(trace, 2000000000) @@ -61,8 +61,8 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): def test_clock_class_offset_ns(self): res = bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-ns': 2}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-ns": 2}, ).query() trace = res[0] self._check(trace, 2) @@ -72,11 +72,11 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): def test_clock_class_offset_both(self): res = bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', + "babeltrace.trace-infos", { - 'inputs': self._inputs, - 'clock-class-offset-s': -2, - 'clock-class-offset-ns': -2, + "inputs": self._inputs, + "clock-class-offset-s": -2, + "clock-class-offset-ns": -2, }, ).query() trace = res[0] @@ -86,32 +86,32 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): with self.assertRaises(bt2._Error): bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-s': "2"}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-s": "2"}, ).query() def test_clock_class_offset_s_wrong_type_none(self): with self.assertRaises(bt2._Error): bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-s': None}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-s": None}, ).query() def test_clock_class_offset_ns_wrong_type(self): with self.assertRaises(bt2._Error): bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-ns': "2"}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-ns": "2"}, ).query() def test_clock_class_offset_ns_wrong_type_none(self): with self.assertRaises(bt2._Error): bt2.QueryExecutor( self._fs, - 'babeltrace.trace-infos', - {'inputs': self._inputs, 'clock-class-offset-ns': None}, + "babeltrace.trace-infos", + {"inputs": self._inputs, "clock-class-offset-ns": None}, ).query() @@ -133,12 +133,12 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase): }, ).query() - if os.environ['BT_TESTS_OS_TYPE'] == 'mingw': + if os.environ["BT_TESTS_OS_TYPE"] == "mingw": os_stream_path = ( - '\\tests\\data\\ctf-traces\\intersection\\3eventsintersect\\' + "\\tests\\data\\ctf-traces\\intersection\\3eventsintersect\\" ) else: - os_stream_path = '/tests/data/ctf-traces/intersection/3eventsintersect/' + os_stream_path = "/tests/data/ctf-traces/intersection/3eventsintersect/" self.assertEqual(len(res), 1) trace = res[0] @@ -164,10 +164,10 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase): {"inputs": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]}, ).query() - if os.environ['BT_TESTS_OS_TYPE'] == 'mingw': - os_stream_path = '\\tests\\data\\ctf-traces\\succeed\\succeed1\\dummystream' + if os.environ["BT_TESTS_OS_TYPE"] == "mingw": + os_stream_path = "\\tests\\data\\ctf-traces\\succeed\\succeed1\\dummystream" else: - os_stream_path = '/tests/data/ctf-traces/succeed/succeed1/dummystream' + os_stream_path = "/tests/data/ctf-traces/succeed/succeed1/dummystream" self.assertEqual(len(res), 1) trace = res[0] @@ -203,8 +203,8 @@ class QueryTraceInfoRangeTestCase(unittest.TestCase): streams = trace["stream-infos"] self.assertEqual(len(streams), 1) - self.assertRaises(KeyError, lambda: trace['range-ns']) - self.assertRaises(KeyError, lambda: streams[0]['range-ns']) + self.assertRaises(KeyError, lambda: trace["range-ns"]) + self.assertRaises(KeyError, lambda: streams[0]["range-ns"]) def test_trace_with_tracefile_rotation(self): res = bt2.QueryExecutor( @@ -231,24 +231,24 @@ class QueryTraceInfoRangeTestCase(unittest.TestCase): # index files, because fix_index_lttng_event_after_packet_bug changes # them based on the time of the last event in the stream. - self.assertEqual(streams[0]['range-ns']['begin'], 1571261795455986789) - self.assertEqual(streams[0]['range-ns']['end'], 1571261797582611840) + self.assertEqual(streams[0]["range-ns"]["begin"], 1571261795455986789) + self.assertEqual(streams[0]["range-ns"]["end"], 1571261797582611840) - self.assertEqual(streams[1]['range-ns']['begin'], 1571261795456368232) - self.assertEqual(streams[1]['range-ns']['end'], 1571261797577754111) + self.assertEqual(streams[1]["range-ns"]["begin"], 1571261795456368232) + self.assertEqual(streams[1]["range-ns"]["end"], 1571261797577754111) - self.assertEqual(streams[2]['range-ns']['begin'], 1571261795456748255) - self.assertEqual(streams[2]['range-ns']['end'], 1571261797577727795) + self.assertEqual(streams[2]["range-ns"]["begin"], 1571261795456748255) + self.assertEqual(streams[2]["range-ns"]["end"], 1571261797577727795) - self.assertEqual(streams[3]['range-ns']['begin'], 1571261795457285142) - self.assertEqual(streams[3]['range-ns']['end'], 1571261797582522088) + self.assertEqual(streams[3]["range-ns"]["begin"], 1571261795457285142) + self.assertEqual(streams[3]["range-ns"]["end"], 1571261797582522088) class QueryTraceInfoPacketTimestampQuirksTestCase(unittest.TestCase): def setUp(self): - ctf = bt2.find_plugin('ctf') - self._fs = ctf.source_component_classes['fs'] - self._path = os.path.join(test_ctf_traces_path, 'succeed') + ctf = bt2.find_plugin("ctf") + self._fs = ctf.source_component_classes["fs"] + self._path = os.path.join(test_ctf_traces_path, "succeed") def _test_lttng_quirks(self, trace_name): res = bt2.QueryExecutor( @@ -265,17 +265,17 @@ class QueryTraceInfoPacketTimestampQuirksTestCase(unittest.TestCase): streams = trace["stream-infos"] self.assertEqual(len(streams), 1) - self.assertEqual(streams[0]['range-ns']['begin'], 1565957300948091100) - self.assertEqual(streams[0]['range-ns']['end'], 1565957302180016069) + self.assertEqual(streams[0]["range-ns"]["begin"], 1565957300948091100) + self.assertEqual(streams[0]["range-ns"]["end"], 1565957302180016069) def test_lttng_crash(self): trace = self._test_lttng_quirks("lttng-crash") streams = trace["stream-infos"] self.assertEqual(len(streams), 1) - self.assertEqual(streams[0]['range-ns']['begin'], 1565891729288866738) - self.assertEqual(streams[0]['range-ns']['end'], 1565891729293526525) + self.assertEqual(streams[0]["range-ns"]["begin"], 1565891729288866738) + self.assertEqual(streams[0]["range-ns"]["end"], 1565891729293526525) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py b/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py index ed018c29..c0baa1d5 100644 --- a/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py +++ b/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py @@ -28,9 +28,9 @@ class MySink(bt2._UserSinkComponent): bt2.register_plugin( __name__, - 'sparkling', - author='Philippe Proulx', - description='A delicious plugin.', - version=(1, 2, 3, 'EXTRA'), - license='MIT', + "sparkling", + author="Philippe Proulx", + description="A delicious plugin.", + version=(1, 2, 3, "EXTRA"), + license="MIT", ) diff --git a/tests/python-plugin-provider/test_python_plugin_provider.py b/tests/python-plugin-provider/test_python_plugin_provider.py index 23494aff..c48d2dc9 100644 --- a/tests/python-plugin-provider/test_python_plugin_provider.py +++ b/tests/python-plugin-provider/test_python_plugin_provider.py @@ -10,21 +10,21 @@ import os class PythonPluginProviderTestCase(unittest.TestCase): def test_python_plugin_provider(self): - path = os.environ['PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH'] + path = os.environ["PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH"] pset = bt2.find_plugins_in_path(path) self.assertEqual(len(pset), 1) plugin = pset[0] - self.assertEqual(plugin.name, 'sparkling') - self.assertEqual(plugin.author, 'Philippe Proulx') - self.assertEqual(plugin.description, 'A delicious plugin.') + self.assertEqual(plugin.name, "sparkling") + self.assertEqual(plugin.author, "Philippe Proulx") + self.assertEqual(plugin.description, "A delicious plugin.") self.assertEqual(plugin.version.major, 1) self.assertEqual(plugin.version.minor, 2) self.assertEqual(plugin.version.patch, 3) - self.assertEqual(plugin.version.extra, 'EXTRA') - self.assertEqual(plugin.license, 'MIT') + self.assertEqual(plugin.version.extra, "EXTRA") + self.assertEqual(plugin.license, "MIT") self.assertEqual(len(plugin.source_component_classes), 1) self.assertEqual(len(plugin.filter_component_classes), 1) self.assertEqual(len(plugin.sink_component_classes), 1) - self.assertEqual(plugin.source_component_classes['MySource'].name, 'MySource') - self.assertEqual(plugin.filter_component_classes['MyFilter'].name, 'MyFilter') - self.assertEqual(plugin.sink_component_classes['MySink'].name, 'MySink') + self.assertEqual(plugin.source_component_classes["MySource"].name, "MySource") + self.assertEqual(plugin.filter_component_classes["MyFilter"].name, "MyFilter") + self.assertEqual(plugin.sink_component_classes["MySink"].name, "MySink") diff --git a/tests/utils/python/cli_params_to_string.py b/tests/utils/python/cli_params_to_string.py index f07755c6..90d61ffd 100644 --- a/tests/utils/python/cli_params_to_string.py +++ b/tests/utils/python/cli_params_to_string.py @@ -12,13 +12,13 @@ def to_string(p): # signed integers). if type(p) is bt2._ArrayValueConst: - s = '[{}]'.format(', '.join([to_string(x) for x in p])) + s = "[{}]".format(", ".join([to_string(x) for x in p])) elif type(p) is bt2._MapValueConst: - s = '{{{}}}'.format( - ', '.join([k + '=' + to_string(p[k]) for k in sorted(p.keys())]) + s = "{{{}}}".format( + ", ".join([k + "=" + to_string(p[k]) for k in sorted(p.keys())]) ) elif type(p) is bt2._UnsignedIntegerValueConst: - s = str(p) + 'u' + s = str(p) + "u" elif ( type(p) in ( @@ -32,6 +32,6 @@ def to_string(p): s = str(p) else: - raise TypeError('Unexpected type', type(p)) + raise TypeError("Unexpected type", type(p)) return s diff --git a/tests/utils/python/split_sort_compare.py b/tests/utils/python/split_sort_compare.py index 3b4f83d5..c57e84e9 100644 --- a/tests/utils/python/split_sort_compare.py +++ b/tests/utils/python/split_sort_compare.py @@ -9,8 +9,8 @@ import re def main(): expected = sys.argv[1] actual = sys.argv[2] - sorted_expected = ''.join(sorted(re.findall(r'\w+|\W+', expected.strip()))) - sorted_actual = ''.join(sorted(re.findall(r'\w+|\W+', actual.strip()))) + sorted_expected = "".join(sorted(re.findall(r"\w+|\W+", expected.strip()))) + sorted_actual = "".join(sorted(re.findall(r"\w+|\W+", actual.strip()))) if sorted_expected == sorted_actual: status = 0 @@ -20,5 +20,5 @@ def main(): sys.exit(status) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/tests/utils/python/testrunner.py b/tests/utils/python/testrunner.py index bcb3d368..a7cd8263 100644 --- a/tests/utils/python/testrunner.py +++ b/tests/utils/python/testrunner.py @@ -9,31 +9,31 @@ import sys import argparse -if __name__ == '__main__': +if __name__ == "__main__": argparser = argparse.ArgumentParser() argparser.add_argument( - '-f', '--failfast', help='Stop on first fail or error', action='store_true' + "-f", "--failfast", help="Stop on first fail or error", action="store_true" ) argparser.add_argument( - 'start_dir', help='Base directory where to search for tests', type=str + "start_dir", help="Base directory where to search for tests", type=str ) mut_exclu_group = argparser.add_mutually_exclusive_group(required=True) mut_exclu_group.add_argument( - '-p', - '--pattern', - help='Glob-style pattern of test files to run ' '(e.g. test_event*.py)', + "-p", + "--pattern", + help="Glob-style pattern of test files to run " "(e.g. test_event*.py)", type=str, ) mut_exclu_group.add_argument( - '-t', - '--test-case', - help='Run a specfic test module name, test class ' - 'name, or test method name ' - '(e.g. test_event.EventTestCase.test_clock_value)', + "-t", + "--test-case", + help="Run a specfic test module name, test class " + "name, or test method name " + "(e.g. test_event.EventTestCase.test_clock_value)", type=str, ) @@ -63,5 +63,5 @@ if __name__ == '__main__': runner = TAPTestRunner(failfast=failfast) runner.set_stream(True) - runner.set_format('{method_name}') + runner.set_format("{method_name}") sys.exit(0 if runner.run(tests).wasSuccessful() else 1) -- 2.34.1