From 833f3367d826e09dee0c007e0d458867cce8ee6c Mon Sep 17 00:00:00 2001 From: Eduardo Mendes Date: Thu, 21 Sep 2017 07:23:12 -0300 Subject: [PATCH] Small adjustments to simplify tests readability (#12) --- tests/test_data/impl_stubs.py | 6 +- tests/test_processor.py | 20 ++-- tests/test_python.py | 86 +++++++++++------ tests/test_refactor.py | 54 ++++++++--- tests/test_registry.py | 173 +++++++++++++++++++++++++--------- 5 files changed, 242 insertions(+), 97 deletions(-) diff --git a/tests/test_data/impl_stubs.py b/tests/test_data/impl_stubs.py index c31d913..7d995ca 100644 --- a/tests/test_data/impl_stubs.py +++ b/tests/test_data/impl_stubs.py @@ -1,5 +1,7 @@ -from getgauge.python import before_step, step, after_step, before_scenario, after_scenario, before_spec, after_spec, \ - before_suite, after_suite, screenshot, continue_on_failure +from getgauge.python import (before_step, step, after_step, before_scenario, + after_scenario, before_spec, after_spec, + before_suite, after_suite, screenshot, + continue_on_failure) @step("Step 1") diff --git a/tests/test_processor.py b/tests/test_processor.py index 849968b..e9659de 100644 --- a/tests/test_processor.py +++ b/tests/test_processor.py @@ -1,5 +1,5 @@ -import socket -import unittest +from socket import socket, AF_INET, SOCK_STREAM +from unittest import TestCase, main from getgauge.messages.messages_pb2 import Message, StepValidateResponse from getgauge.messages.spec_pb2 import ProtoExecutionResult, Parameter @@ -8,7 +8,7 @@ from getgauge.registry import registry -class ProcessorTests(unittest.TestCase): +class ProcessorTests(TestCase): def setUp(self): DataStoreFactory.suite_data_store().clear() DataStoreFactory.spec_data_store().clear() @@ -20,7 +20,10 @@ def tearDown(self): def test_Processor_kill_request(self): with self.assertRaises(SystemExit): - processors[Message.KillProcessRequest](None, None, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) + processors[Message.KillProcessRequest](None, + None, + socket(AF_INET, + SOCK_STREAM)) def test_Processor_suite_data_store_init_request(self): DataStoreFactory.suite_data_store().put('suite', 'value') @@ -31,8 +34,11 @@ def test_Processor_suite_data_store_init_request(self): processors[Message.SuiteDataStoreInit](None, response, None) self.assertEqual(Message.ExecutionStatusResponse, response.messageType) - self.assertEqual(False, response.executionStatusResponse.executionResult.failed) - self.assertEqual(0, response.executionStatusResponse.executionResult.executionTime) + self.assertEqual(False, + response.executionStatusResponse.executionResult.failed) + + self.assertEqual(0, + response.executionStatusResponse.executionResult.executionTime) self.assertEqual(DataStore(), DataStoreFactory.suite_data_store()) @@ -434,4 +440,4 @@ def failing_impl(): if __name__ == '__main__': - unittest.main() + main() diff --git a/tests/test_python.py b/tests/test_python.py index 1fc2143..8e48383 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -1,15 +1,15 @@ -import unittest +from unittest import TestCase, main from getgauge.messages.messages_pb2 import Message -from getgauge.python import Messages, DataStore, DataStoreFactory, Table, Specification, Scenario, Step, \ - ExecutionContext, \ - create_execution_context_from from getgauge.registry import registry, _MessagesStore +from getgauge.python import (Messages, DataStore, DataStoreFactory, Table, + Specification, Scenario, Step, ExecutionContext, + create_execution_context_from) registry.clear() -class MessagesTests(unittest.TestCase): +class MessagesTests(TestCase): def test_pending_messages(self): messages = ['HAHAHAH', 'HAHAHAH1', 'HAHAHAH2', 'HAHAHAH3'] for message in messages: @@ -45,10 +45,14 @@ def test_pending_messages_gives_only_those_messages_which_are_not_reported(self) self.assertEqual(messages, pending_messages) -class DataStoreTests(unittest.TestCase): +class DataStoreTests(TestCase): def test_data_store(self): store = DataStore() - values = {'key': 'HAHAHAH', 'key1': 'HAHAHAH1', 'key2': 'HAHAHAH2', 'key3': 'HAHAHAH3'} + values = {'key': 'HAHAHAH', + 'key1': 'HAHAHAH1', + 'key2': 'HAHAHAH2', + 'key3': 'HAHAHAH3'} + for value in values: store.put(value, value) @@ -60,7 +64,11 @@ def test_data_store(self): def test_data_store_clear(self): store = DataStore() - values = {'key': 'HAHAHAH', 'key1': 'HAHAHAH1', 'key2': 'HAHAHAH2', 'key3': 'HAHAHAH3'} + values = {'key': 'HAHAHAH', + 'key1': 'HAHAHAH1', + 'key2': 'HAHAHAH2', + 'key3': 'HAHAHAH3'} + for value in values: store.put(value, value) @@ -92,7 +100,7 @@ def test_data_store_equality(self): self.assertNotEqual(store, store1) -class DataStoreFactoryTests(unittest.TestCase): +class DataStoreFactoryTests(TestCase): def test_data_store_factory(self): scenario_data_store = DataStoreFactory.scenario_data_store() spec_data_store = DataStoreFactory.spec_data_store() @@ -116,7 +124,7 @@ def __init__(self, cells): self.cells = cells -class TableTests(unittest.TestCase): +class TableTests(TestCase): def test_Table(self): headers = ['Product', 'Description'] rows = [{'cells': ['Gauge', 'Test automation with ease']}, @@ -134,10 +142,15 @@ def test_Table(self): self.assertEqual(headers, table.headers) self.assertEqual(expected_rows, table.rows) - self.assertEqual(expected_column_1, table.get_column_values_with_index(1)) - self.assertEqual(expected_column_2, table.get_column_values_with_index(2)) - self.assertEqual(expected_column_1, table.get_column_values_with_name(headers[0])) - self.assertEqual(expected_column_2, table.get_column_values_with_name(headers[1])) + self.assertEqual(expected_column_1, + table.get_column_values_with_index(1)) + self.assertEqual(expected_column_2, + table.get_column_values_with_index(2)) + self.assertEqual(expected_column_1, + table.get_column_values_with_name(headers[0])) + self.assertEqual(expected_column_2, + table.get_column_values_with_name(headers[1])) + for row in expected_rows: self.assertEqual(row, table.get_row(expected_rows.index(row) + 1)) @@ -212,7 +225,7 @@ def test_Table__str__without_rows(self): |----|-----------|""") -class SpecificationTests(unittest.TestCase): +class SpecificationTests(TestCase): def test_Specification(self): name = 'NAME' file_name = 'FILE_NAME' @@ -234,7 +247,7 @@ def test_Specification_equality(self): self.assertEqual(specification, specification1) -class ScenarioTests(unittest.TestCase): +class ScenarioTests(TestCase): def test_Scenario(self): name = 'NAME3' tags = ['TAGS'] @@ -253,7 +266,7 @@ def test_Scenario_equality(self): self.assertEqual(scenario, scenario1) -class StepTests(unittest.TestCase): +class StepTests(TestCase): def test_Step(self): name = 'NAME1' step = Step(name, False) @@ -269,7 +282,7 @@ def test_Step_equality(self): self.assertEqual(step, step1) -class ExecutionContextTests(unittest.TestCase): +class ExecutionContextTests(TestCase): def test_ExecutionContextTests(self): name = 'NAME' file_name = 'FILE_NAME' @@ -298,14 +311,25 @@ def test_ExecutionContextTests_equality(self): def test_create_execution_context_from(self): message = Message() - spec_name, spec_file_name, scenario_name, step_name = 'SPEC_NAME', 'SPEC_FILE_NAME', 'SCENARIO_NAME', 'STEP_NAME' - message.executionStartingRequest.currentExecutionInfo.currentSpec.name = spec_name - message.executionStartingRequest.currentExecutionInfo.currentSpec.fileName = spec_file_name - message.executionStartingRequest.currentExecutionInfo.currentSpec.isFailed = True - message.executionStartingRequest.currentExecutionInfo.currentScenario.name = scenario_name - message.executionStartingRequest.currentExecutionInfo.currentScenario.isFailed = False - message.executionStartingRequest.currentExecutionInfo.currentStep.step.actualStepText = step_name - message.executionStartingRequest.currentExecutionInfo.currentStep.isFailed = True + spec_name = 'SPEC_NAME' + spec_file_name = 'SPEC_FILE_NAME' + scenario_name = 'SCENARIO_NAME' + step_name = 'STEP_NAME' + + message.executionStartingRequest.\ + currentExecutionInfo.currentSpec.name = spec_name + message.executionStartingRequest.\ + currentExecutionInfo.currentSpec.fileName = spec_file_name + message.executionStartingRequest.\ + currentExecutionInfo.currentSpec.isFailed = True + message.executionStartingRequest.\ + currentExecutionInfo.currentScenario.name = scenario_name + message.executionStartingRequest.\ + currentExecutionInfo.currentScenario.isFailed = False + message.executionStartingRequest.\ + currentExecutionInfo.currentStep.step.actualStepText = step_name + message.executionStartingRequest.\ + currentExecutionInfo.currentStep.isFailed = True specification = Specification(spec_name, spec_file_name, True, []) scenario = Scenario(scenario_name, False, []) @@ -318,7 +342,7 @@ def test_create_execution_context_from(self): self.assertEqual(expected_execution_context, context) -class DecoratorTests(unittest.TestCase): +class DecoratorTests(TestCase): def setUp(self): from tests.test_data import impl_stubs impl_stubs.step1() @@ -332,8 +356,10 @@ def test_continue_on_failure(self): step1 = registry.get_info_for('Step 1').impl step2 = registry.get_info_for('Step 2').impl - self.assertEqual(registry.is_continue_on_failure(step1, RuntimeError()), False) - self.assertEqual(registry.is_continue_on_failure(step2, RuntimeError()), True) + self.assertEqual( + registry.is_continue_on_failure(step1, RuntimeError()), False) + self.assertEqual( + registry.is_continue_on_failure(step2, RuntimeError()), True) def test_before_step_decorator(self): funcs = registry.before_step() @@ -382,4 +408,4 @@ def test_screenshot_decorator(self): if __name__ == '__main__': - unittest.main() + main() diff --git a/tests/test_refactor.py b/tests/test_refactor.py index f48e8b7..c7fe02e 100644 --- a/tests/test_refactor.py +++ b/tests/test_refactor.py @@ -50,8 +50,13 @@ def test_Processor_refactor_request_with_add_param(self): actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is .") def assert_default_vowels(given_vowels, bsdfdsf): Messages.write_message("Given vowels are {0}".format(given_vowels)) @@ -80,8 +85,13 @@ def test_Processor_refactor_request_with_add_param_and_invalid_identifier(self): actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is .") def assert_default_vowels(given_vowels, arg1): Messages.write_message("Given vowels are {0}".format(given_vowels)) @@ -110,8 +120,13 @@ def test_Processor_refactor_request_with_add_param_and_only_invalid_identifier(s actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is .") def assert_default_vowels(given_vowels, arg1): Messages.write_message("Given vowels are {0}".format(given_vowels)) @@ -132,8 +147,13 @@ def test_Processor_refactor_request_with_remove_param(self): actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is.") def assert_default_vowels(): Messages.write_message("Given vowels are {0}".format(given_vowels)) @@ -159,8 +179,13 @@ def test_Processor_refactor_request(self): actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is .") def assert_default_vowels(given_vowels): Messages.write_message("Given vowels are {0}".format(given_vowels)) @@ -186,8 +211,13 @@ def test_Processor_refactor_request_with_add_and_remove_param(self): actual_data = self.getActualText() self.assertEqual(Message.RefactorResponse, response.messageType) - self.assertEqual(True, response.refactorResponse.success, response.refactorResponse.error) - self.assertEqual([RefactorTests.path], response.refactorResponse.filesChanged) + self.assertEqual(True, + response.refactorResponse.success, + response.refactorResponse.error) + + self.assertEqual([RefactorTests.path], + response.refactorResponse.filesChanged) + expected = """@step("Vowels in English language is .") def assert_default_vowels(bsdfdsf): Messages.write_message("Given vowels are {0}".format(given_vowels)) diff --git a/tests/test_registry.py b/tests/test_registry.py index 1ce74a9..f3813d5 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -10,32 +10,42 @@ def setUp(self): registry = Registry() def test_Registry_add_step_definition(self): - infos = [{'text': 'Say to ', 'func': 'func'}, {'text': 'Step 1', 'func': 'func1'}] + infos = [{'text': 'Say to ', 'func': 'func'}, + {'text': 'Step 1', 'func': 'func1'}] + for info in infos: registry.add_step(info['text'], info['func'], '') - self.assertEqual([info['text'] for info in infos].sort(), registry.steps().sort()) + self.assertEqual([info['text'] for info in infos].sort(), + registry.steps().sort()) + for info in infos: parsed_step_text = re.sub('<[^<]+?>', '{}', info['text']) - self.assertEqual(info['func'], registry.get_info_for(parsed_step_text).impl) + self.assertEqual(info['func'], + registry.get_info_for(parsed_step_text).impl) def test_Registry_add_step_definition_with_continue_on_failure(self): registry.add_step('Step 1', 'func', '') registry.continue_on_failure('func', [RuntimeError]) - self.assertEqual(True, registry.is_continue_on_failure('func', RuntimeError())) + self.assertEqual(True, + registry.is_continue_on_failure('func', + RuntimeError())) def test_Registry_add_step_definition_with_continue_on_failure_for_different_exceptions(self): registry.add_step('Step 1', 'func', '') registry.continue_on_failure('func', [RuntimeError]) - self.assertEqual(False, registry.is_continue_on_failure('func', IndexError())) + self.assertEqual(False, + registry.is_continue_on_failure('func', IndexError())) def test_Registry_add_step_definition_with_parent_class_continue_on_failure(self): registry.add_step('Step 1', 'func', '') registry.continue_on_failure('func', [Exception]) - self.assertEqual(True, registry.is_continue_on_failure('func', RuntimeError())) + self.assertEqual(True, + registry.is_continue_on_failure('func', + RuntimeError())) def test_Registry_add_step_definition_with_alias(self): registry.add_step(['Say to .', 'Tell to .'], 'impl', '') @@ -47,17 +57,26 @@ def test_Registry_add_step_definition_with_alias(self): self.assertEqual(info2.has_alias, True) def test_Registry_get_step_info(self): - infos = [{'text': 'Say to ', 'func': 'func'}, {'text': 'Step 1', 'func': 'func1'}] + infos = [{'text': 'Say to ', 'func': 'func'}, + {'text': 'Step 1', 'func': 'func1'}] + for info in infos: registry.add_step(info['text'], info['func'], '') - self.assertEqual('Say to ', registry.get_info_for('Say {} to {}').step_text) - self.assertEqual('Say {} to {}', registry.get_info_for('Say {} to {}').parsed_step_text) + self.assertEqual('Say to ', + registry.get_info_for('Say {} to {}').step_text) + + self.assertEqual('Say {} to {}', + registry.get_info_for('Say {} to {}').parsed_step_text) + self.assertEqual('Step 1', registry.get_info_for('Step 1').step_text) + self.assertEqual(None, registry.get_info_for('Step21').step_text) def test_Registry_is_step_implemented(self): - infos = [{'text': 'Say to ', 'func': 'func'}, {'text': 'Step 1', 'func': 'func1'}] + infos = [{'text': 'Say to ', 'func': 'func'}, + {'text': 'Step 1', 'func': 'func1'}] + for info in infos: registry.add_step(info['text'], info['func'], '') @@ -78,19 +97,27 @@ def test_Registry_has_multiple_impls(self): self.assertFalse(registry.has_multiple_impls(infos[2]['text'])) def test_Registry_get_multiple_impls(self): - infos = [{'text': 'Say to ', 'func': 'func', 'line': 1}, - {'text': 'Say to ', 'func': 'func', 'line': 2}, + infos = [{'text': 'Say to ', + 'func': 'func', 'line': 1}, + {'text': 'Say to ', + 'func': 'func', 'line': 2}, {'text': 'Step 1', 'func': 'func1', 'line': 3}] + for info in infos: registry.add_step(info['text'], info['func'], '', info['line']) parsed_step_text = re.sub('<[^<]+?>', '{}', infos[0]['text']) self.assertTrue(registry.has_multiple_impls(parsed_step_text)) - self.assertEqual(set([info.line_number for info in registry.get_infos_for(parsed_step_text)]), - {infos[0]['line'], infos[1]['line']}) - self.assertEqual(set([info.step_text for info in registry.get_infos_for(parsed_step_text)]), - {infos[0]['text'], infos[1]['text']}) + self.assertEqual( + set([info.line_number + for info in registry.get_infos_for(parsed_step_text)]), + {infos[0]['line'], infos[1]['line']}) + + self.assertEqual( + set([info.step_text + for info in registry.get_infos_for(parsed_step_text)]), + {infos[0]['text'], infos[1]['text']}) def test_Registry_before_suite(self): infos = ['before suite func', 'before suite func1'] @@ -122,30 +149,47 @@ def test_Registry_after_spec(self): def test_Registry_before_spec_with_tags(self): info1 = {'tags': None, 'func': 'before spec func'} - info2 = {'tags': ' and and not ', 'func': 'before spec func1'} - info3 = {'tags': ' and ( or not )', 'func': 'before spec func2'} + info2 = {'tags': ' and and not ', + 'func': 'before spec func1'} + info3 = {'tags': ' and ( or not )', + 'func': 'before spec func2'} infos = [info1, info2, info3] + for info in infos: registry.add_before_spec(info['func'], info['tags']) self.assertEqual([info1['func']], registry.before_spec([])) - self.assertEqual([x['func'] for x in infos], registry.before_spec(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.before_spec(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.before_spec(['A'])) + self.assertEqual([x['func'] for x in infos], + registry.before_spec(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_spec(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_spec(['A'])) + self.assertEqual([info1['func']], registry.before_spec(['A', 'c'])) def test_Registry_after_spec_with_tags(self): info1 = {'tags': None, 'func': 'after spec func'} info2 = {'tags': ' and and not ', 'func': 'after spec func1'} - info3 = {'tags': ' and ( or not )', 'func': 'after spec func2'} + info3 = {'tags': ' and ( or not )', + 'func': 'after spec func2'} infos = [info1, info2, info3] + for info in infos: registry.add_after_spec(info['func'], info['tags']) self.assertEqual([info1['func']], registry.after_spec([])) - self.assertEqual([x['func'] for x in infos], registry.after_spec(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.after_spec(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.after_spec(['A'])) + self.assertEqual([x['func'] for x in infos], + registry.after_spec(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_spec(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_spec(['A'])) + self.assertEqual([info1['func']], registry.after_spec(['A', 'c'])) def test_Registry_before_scenario(self): @@ -164,30 +208,50 @@ def test_Registry_after_scenario(self): def test_Registry_before_scenario_with_tags(self): info1 = {'tags': None, 'func': 'before scenario func'} - info2 = {'tags': ' and and not ', 'func': 'before scenario func1'} - info3 = {'tags': ' and ( or not )', 'func': 'before scenario func2'} + info2 = {'tags': ' and and not ', + 'func': 'before scenario func1'} + info3 = {'tags': ' and ( or not )', + 'func': 'before scenario func2'} infos = [info1, info2, info3] + for info in infos: registry.add_before_scenario(info['func'], info['tags']) - self.assertEqual([info1['func']], registry.before_scenario([])) - self.assertEqual([x['func'] for x in infos], registry.before_scenario(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.before_scenario(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.before_scenario(['A'])) + self.assertEqual([info1['func']], + registry.before_scenario([])) + + self.assertEqual([x['func'] for x in infos], + registry.before_scenario(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_scenario(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_scenario(['A'])) + self.assertEqual([info1['func']], registry.before_scenario(['A', 'c'])) def test_Registry_after_scenario_with_tags(self): info1 = {'tags': None, 'func': 'after scenario func'} - info2 = {'tags': ' and and not ', 'func': 'after scenario func1'} - info3 = {'tags': ' and ( or not )', 'func': 'after scenario func2'} + info2 = {'tags': ' and and not ', + 'func': 'after scenario func1'} + info3 = {'tags': ' and ( or not )', + 'func': 'after scenario func2'} infos = [info1, info2, info3] + for info in infos: registry.add_after_scenario(info['func'], info['tags']) self.assertEqual([info1['func']], registry.after_scenario([])) - self.assertEqual([x['func'] for x in infos], registry.after_scenario(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.after_scenario(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.after_scenario(['A'])) + self.assertEqual([x['func'] for x in infos], + registry.after_scenario(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_scenario(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_scenario(['A'])) + self.assertEqual([info1['func']], registry.after_scenario(['A', 'c'])) def test_Registry_before_step(self): @@ -206,30 +270,47 @@ def test_Registry_after_step(self): def test_Registry_before_step_with_tags(self): info1 = {'tags': None, 'func': 'before step func'} - info2 = {'tags': ' and and not ', 'func': 'before step func1'} - info3 = {'tags': ' and ( or not )', 'func': 'before step func2'} + info2 = {'tags': ' and and not ', + 'func': 'before step func1'} + info3 = {'tags': ' and ( or not )', + 'func': 'before step func2'} infos = [info1, info2, info3] + for info in infos: registry.add_before_step(info['func'], info['tags']) self.assertEqual([info1['func']], registry.before_step([])) - self.assertEqual([x['func'] for x in infos], registry.before_step(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.before_step(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.before_step(['A'])) + self.assertEqual([x['func'] for x in infos], + registry.before_step(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_step(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.before_step(['A'])) + self.assertEqual([info1['func']], registry.before_step(['A', 'c'])) def test_Registry_after_step_with_tags(self): info1 = {'tags': None, 'func': 'after step func'} - info2 = {'tags': ' and and not ', 'func': 'after step func1'} - info3 = {'tags': ' and ( or not )', 'func': 'after step func2'} + info2 = {'tags': ' and and not ', + 'func': 'after step func1'} + info3 = {'tags': ' and ( or not )', + 'func': 'after step func2'} infos = [info1, info2, info3] + for info in infos: registry.add_after_step(info['func'], info['tags']) self.assertEqual([info1['func']], registry.after_step([])) - self.assertEqual([x['func'] for x in infos], registry.after_step(['A', 'b'])) - self.assertEqual([info1['func'], info3['func']], registry.after_step(['A', 'b', 'c'])) - self.assertEqual([info1['func'], info3['func']], registry.after_step(['A'])) + self.assertEqual([x['func'] for x in infos], + registry.after_step(['A', 'b'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_step(['A', 'b', 'c'])) + + self.assertEqual([info1['func'], info3['func']], + registry.after_step(['A'])) self.assertEqual([info1['func']], registry.after_step(['A', 'c'])) def tearDown(self):