X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Flib%2Fconds%2Ftest.py;h=d8e5fe2e8d803b7ca0156157ca712f2b58be5bb7;hp=0f39d2ac4e04e39c41e71b26e9374e6ff5e8d796;hb=f5567ea88d172767b34373bc6e402da8bfd85ef8;hpb=419d8c49bd978a59b8a0619d83cb6ba26b18f970 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()