def test_selecting_an_element_from_a_stored_list_returns_the_value_and_stores_it_in_the_actors_state(): user = Actor('user') user.state['list'].set(['a', 'b', 'c', 'd']) returned_value = user.attempts_to( select_element_at_index(1).from_stored_list('list').and_store_in('found') ) assert returned_value == 'b', "Returned value was incorrect" assert user.state['found'].value == 'b', "Stored value was incorrect"
def test_The_log_indent_is_restored_if_a_test_fails(): user = Actor('user') Log.to_actions() original_indent = _LogIndent.current_indent try: user.attempts_to(failing_task()) except AssertionError: pass assert original_indent == _LogIndent.current_indent, 'The indent was not reset if an action fails'
def test_an_attempted_out_of_bounds_access_causes_an_assertion(): user = Actor('user') user.state['list'].set(['a']) with pytest.raises(AssertionError) as exception: user.attempts_to( select_element_at_index(1).from_stored_list('list').and_store_in( 'found')) expected = "'list' does not have enough elements to access element 1" actual = exception.value.args[0] assert actual == expected, "Incorrect message\nExpected: {expected}\nActual:{actual}".format( expected=expected, actual=actual)
def test_The_log_indent_is_not_increased_by_actions_if_only_logging_to_tasks(): user = Actor('user') Log.to_tasks() start_indent = _LogIndent.current_indent action = record_log_indent_action() task = record_log_indent_task(action) user.attempts_to(task) assert task.indent == start_indent + 2, 'Task not indented correctly' assert action.indent == start_indent + 2, 'Action not indented correctly'