def test_generates_full_test_case_for_a_call(self): alist = create(SequenceObject) call = create(FunctionCall, args={}, output=alist) put_on_timeline(call, alist) code_string = generate_test_case(call, template=unittest_template) assert_equal_strings("self.assertEqual([], function())\n", code_string) assert_equal(set([('module', 'function')]), code_string.imports)
def test_doesnt_include_side_effects_of_method_calls_into_user_object_test_case(self): klass = Class("UserClass") user_obj = UserObject(None, klass) init = Method("__init__", klass=klass) init_call = MethodCall(definition=init, args={}, output=user_obj) method1 = Method("method1", klass=klass) method1_call = MethodCall(definition=method1, args={}, output=create(ImmutableObject)) se1 = GlobalRebind('mod', 'var', ImmutableObject('new_value')) method1_call.add_side_effect(se1) method2 = Method("method2", klass=klass) method2_call = MethodCall(definition=method2, args={}, output=create(ImmutableObject)) se2 = AttributeRebind(user_obj, 'attr', create(ImmutableObject, obj=1)) method2_call.add_side_effect(se2) user_obj.add_call(init_call) user_obj.add_call(method1_call) user_obj.add_call(method2_call) put_on_timeline(user_obj, init_call, method1_call, se1, method2_call, se2) assert_equal_types(assertions_for_interaction(user_obj), [UserObject, EqualAssertionLine, EqualAssertionLine, EqualAssertionLine, EqualAssertionLine, ImmutableObject, ImmutableObject])
def test_overwrites_existing_test_methods_with_force_option(self): test_method = create(TestMethod, name="test_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # Let's try adding the same method again with a force option # set to True. new_test_method = create(TestMethod, name="test_method") new_test_class = create(TestClass, name="TestSomething", test_cases=[new_test_method]) add_test_case_to_project(self.project, new_test_class, force=True) # The class is still the same. assert_equal([self.existing_test_class], get_test_cases(self.project)) # But the method got replaced. assert_equal([new_test_method], get_test_cases(self.project)[0].test_cases) # The right message was issued. assert_contains_once( self._get_log_output(), "Replacing TestSomething.test_method from test_module.py with generated version." )
def test_doesnt_include_side_effects_of_method_calls_into_user_object_test_case( self): klass = Class("UserClass") user_obj = UserObject(None, klass) init = Method("__init__", klass=klass) init_call = MethodCall(definition=init, args={}, output=user_obj) method1 = Method("method1", klass=klass) method1_call = MethodCall(definition=method1, args={}, output=create(ImmutableObject)) se1 = GlobalRebind('mod', 'var', ImmutableObject('new_value')) method1_call.add_side_effect(se1) method2 = Method("method2", klass=klass) method2_call = MethodCall(definition=method2, args={}, output=create(ImmutableObject)) se2 = AttributeRebind(user_obj, 'attr', create(ImmutableObject, obj=1)) method2_call.add_side_effect(se2) user_obj.add_call(init_call) user_obj.add_call(method1_call) user_obj.add_call(method2_call) put_on_timeline(user_obj, init_call, method1_call, se1, method2_call, se2) assert_equal_types(assertions_for_interaction(user_obj), [ UserObject, EqualAssertionLine, EqualAssertionLine, EqualAssertionLine, EqualAssertionLine, ImmutableObject, ImmutableObject ])
def test_removes_all_immutable_objects(self): obj = create(ImmutableObject) call = create(FunctionCall, args={'x': obj}, output=obj, definition=create(Function, args=['x'])) put_on_timeline(obj, call) assert_equal([call], remove_objects_unworthy_of_naming([obj, call]))
def test_keeps_objects_affected_by_side_effects(self): output = create(SequenceObject) seq = create(SequenceObject, obj=[1]) call = create(FunctionCall, output=output) se = SideEffect([output, seq], []) put_on_timeline(seq, se, output, call) assert_equal([seq, se, output, call], remove_objects_unworthy_of_naming([seq, se, output, call]))
def test_names_output_when_it_was_a_part_of_input(self): function = create(Function, args=['x'], module=None) obj1 = create(SequenceObject) obj2 = create(SequenceObject) alist = create(SequenceObject, obj=[obj1, obj2], serialize=lambda x:x) call = create(FunctionCall, args={'x': alist}, output=obj1, definition=function) result = generate_single_test_module(objects=[function]) assert_contains(result, "alist = []") assert_contains(result, "self.assertEqual(alist, function([alist, []]))")
def test_replacing_a_test_case_removes_it_from_the_list_of_objects_and_list_of_test_cases(self): project = EmptyProject() module = project.create_module("module.py", code=parse("# only comments")) test_class = create(TestClass, name="TestSomething") new_test_class = create(TestClass, name="TestSomethingElse") add_test_case(module, test_class) replace_test_case(module, test_class, new_test_class) assert_equal([new_test_class], module.objects) assert_equal([new_test_class], module.test_cases)
def test_adds_new_test_methods_to_existing_test_classes(self): test_method = create(TestMethod, name="test_new_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_length(get_test_cases(self.project), 1) assert get_test_cases(self.project)[0] is test_method.parent assert test_method.parent is not test_class # The right message was issued. assert_contains_once(self._get_log_output(), "Adding generated test_new_method to TestSomething in test_module.py.")
def test_keeps_objects_used_more_than_once(self): alist = create(SequenceObject) call = create(FunctionCall, args={ 'x': alist, 'y': alist }, definition=create(Function, args=['x', 'y'])) put_on_timeline(alist, call) assert_equal([alist, call], remove_objects_unworthy_of_naming([alist, call]))
def test_names_objects_appropriatelly(self): obj = create(SequenceObject) call = create(FunctionCall, args={'x': obj}, output=obj, definition=create(Function, args=['x'])) obj2 = create(SequenceObject) put_on_timeline(obj, call, obj2) timeline = name_objects_on_timeline([obj, call, obj2]) assert_assignment(timeline[0], 'alist1', obj) assert_equal(call, timeline[1]) assert_assignment(timeline[2], 'alist2', obj2)
def test_removes_objects_only_referenced_by_side_effects(self): seq = create(SequenceObject, obj=[1]) output = create(SequenceObject) se = SideEffect([output], [seq]) call = create(FunctionCall, args={'x': seq}, output=output, definition=create(Function, args=['x'])) put_on_timeline(seq, output, se, call) assert_equal([output, se, call], remove_objects_unworthy_of_naming([seq, output, se, call]))
def test_adds_new_test_methods_to_existing_test_classes_inside_application_modules(self): project = EmptyProject().with_module("somethings.py") test_class = create(TestClass, name="TestSomething") add_test_case(project["somethings"], test_class) method = create(TestMethod) generated_test_class = create(TestClass, name="TestSomething", test_cases=[method]) add_test_case_to_project(project, generated_test_class) assert_length(get_test_cases(project), 1) assert_equal_sets([method], test_class.test_cases) assert method.parent is test_class
def test_replacing_a_test_case_removes_it_from_the_list_of_objects_and_list_of_test_cases( self): project = EmptyProject() module = project.create_module("module.py", code=parse("# only comments")) test_class = create(TestClass, name="TestSomething") new_test_class = create(TestClass, name="TestSomethingElse") add_test_case(module, test_class) replace_test_case(module, test_class, new_test_class) assert_equal([new_test_class], module.objects) assert_equal([new_test_class], module.test_cases)
def test_generates_full_test_case_for_a_call_with_side_effects_and_two_assertions_required(self): alist = create(SequenceObject) call = create(FunctionCall, args={'x': alist}, output=alist, definition=create(Function, args=['x'])) se = ListAppend(alist, create(ImmutableObject, obj=1)) call.add_side_effect(se) put_on_timeline(alist, call, se) assert_equal_strings("alist1 = []\n" "alist2 = []\n" "self.assertEqual(alist1, function(alist1))\n" "alist2.append(1)\n" "self.assertEqual(alist2, alist1)\n", generate_test_case(call, template=unittest_template))
def test_adds_new_test_methods_to_existing_test_classes_inside_application_modules( self): project = EmptyProject().with_module("somethings.py") test_class = create(TestClass, name="TestSomething") add_test_case(project["somethings"], test_class) method = create(TestMethod) generated_test_class = create(TestClass, name="TestSomething", test_cases=[method]) add_test_case_to_project(project, generated_test_class) assert_length(get_test_cases(project), 1) assert_equal_sets([method], test_class.test_cases) assert method.parent is test_class
def test_adds_new_test_methods_to_existing_test_classes(self): test_method = create(TestMethod, name="test_new_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_length(get_test_cases(self.project), 1) assert get_test_cases(self.project)[0] is test_method.parent assert test_method.parent is not test_class # The right message was issued. assert_contains_once( self._get_log_output(), "Adding generated test_new_method to TestSomething in test_module.py." )
def test_generates_side_effect_line_for_user_object_attribute_change(self): klass = Class("UserClass", module=Module(None, 'user_module')) user_obj = UserObject(None, klass) assign = Assign('user_obj', user_obj, 1) se = AttributeRebind(user_obj, 'attr', create(ImmutableObject, obj=1)) assert_equal_strings("user_obj = UserClass()\nuser_obj.attr = 1\n", generate_test_contents([assign, se], None))
def test_adds_new_test_classes_to_existing_test_module(self): test_class = create(TestClass, name="TestSomethingNew", associated_modules=[self.project.create_module("module.py")]) add_test_case_to_project(self.project, test_class) assert_equal_sets([self.existing_test_class, test_class], get_test_cases(self.project))
def test_creates_setup_and_teardown_for_two_different_global_read_side_effects( self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod', 'var', old_value) se2 = GlobalRead('mod', 'other_var', old_value) call.add_side_effect(se) call.add_side_effect(se2) put_on_timeline(se, se2, call, call.output) timeline = assertions_for_interaction(call) varSetup1, varSetup2, varTeardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 7, [2, 3, 5]) assert_assignment_with_module_variable_reference( varSetup1, 'old_mod_var', 'mod', 'var') assert_assignment(varSetup2, 'mod.var', old_value) assert_assignment(varTeardown, 'mod.var', 'old_mod_var') otherVarSetup1, otherVarSetup2, otherVarTeardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 7, [0, 1, 6]) assert_assignment_with_module_variable_reference( otherVarSetup1, 'old_mod_other_var', 'mod', 'other_var') assert_assignment(otherVarSetup2, 'mod.other_var', old_value) assert_assignment(otherVarTeardown, 'mod.other_var', 'old_mod_other_var')
def setUp(self): CapturedLogger.setUp(self) self.project = EmptyProject() self.existing_test_class = create(TestClass, name="TestSomething") self.test_module = self.project.create_module("test_module.py", code=EmptyCode()) add_test_case(self.test_module, self.existing_test_class)
def test_doesnt_include_relevant_objects_affected_by_side_effects_in_the_output(self): alist2 = create(SequenceObject) se = SideEffect([self.alist, alist2], []) create_parent_call_with_side_effects(self.call, [se]) put_on_timeline(self.alist, alist2, se, self.call, self.aline) assert_equal([(self.alist, 2)], object_usage_counts(self.aline))
def test_should_not_touch_modules_with_errors(self): project = EmptyProject() module = project.create_module("module.py") test_module = project.create_module("test_module.py", errors=[Exception()]) add_test_case_to_project(project, create(TestClass, associated_modules=[module])) assert test_module.changed is False
def test_doesnt_include_relevant_objects_affected_by_side_effects_in_the_output( self): alist2 = create(SequenceObject) se = SideEffect([self.alist, alist2], []) create_parent_call_with_side_effects(self.call, [se]) put_on_timeline(self.alist, alist2, se, self.call, self.aline) assert_equal([(self.alist, 2)], object_usage_counts(self.aline))
def test_should_not_touch_modules_with_errors(self): project = EmptyProject() module = project.create_module("module.py") test_module = project.create_module("test_module.py", errors=[Exception()]) add_test_case_to_project( project, create(TestClass, associated_modules=[module])) assert test_module.changed is False
def test_generates_full_test_case_for_a_call_with_side_effects_and_two_assertions_required( self): alist = create(SequenceObject) call = create(FunctionCall, args={'x': alist}, output=alist, definition=create(Function, args=['x'])) se = ListAppend(alist, create(ImmutableObject, obj=1)) call.add_side_effect(se) put_on_timeline(alist, call, se) assert_equal_strings( "alist1 = []\n" "alist2 = []\n" "self.assertEqual(alist1, function(alist1))\n" "alist2.append(1)\n" "self.assertEqual(alist2, alist1)\n", generate_test_case(call, template=unittest_template))
def test_should_emit_warning_when_trying_to_add_test_to_module_with_errors(self): project = EmptyProject() module = project.create_module("module.py") project.create_module("test_module.py", errors=[Exception()]) add_test_case_to_project(project, create(TestClass, name="FooTest", associated_modules=[module])) assert_contains_once(self._get_log_output(), "WARNING: Not adding FooTest to test_module.py, because " "of a failed inspection.")
def test_attaches_test_class_to_test_module_with_most_test_cases_for_associated_module(self): self.project.create_module("irrelevant_test_module.py") self._associate_module_with_existing_test_class() new_test_class = create(TestClass, name="new", associated_modules=[self.associated_module]) add_test_case_to_project(self.project, new_test_class) assert new_test_class in self.test_module.test_cases
def test_adds_new_test_classes_to_existing_test_module(self): test_class = create( TestClass, name="TestSomethingNew", associated_modules=[self.project.create_module("module.py")]) add_test_case_to_project(self.project, test_class) assert_equal_sets([self.existing_test_class, test_class], get_test_cases(self.project))
def test_replaces_module_instance_in_test_cases_associated_modules_during_module_replacement(self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) test_class = create(TestClass, name='TestAnything', associated_modules=[project[P("other/module.py")]]) add_test_case(project[P("other/module.py")], test_class) new_module = project.create_module(P("other/module.py")) assert_length(test_class.associated_modules, 1) assert test_class.associated_modules[0] is new_module
def test_attaches_test_class_to_test_module_with_most_test_cases_for_associated_module( self): self.project.create_module("irrelevant_test_module.py") self._associate_module_with_existing_test_class() new_test_class = create(TestClass, name="new", associated_modules=[self.associated_module]) add_test_case_to_project(self.project, new_test_class) assert new_test_class in self.test_module.test_cases
def test_doesnt_overwrite_existing_test_methods_by_default(self): test_method = create(TestMethod, name="test_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # Let's try adding the same method again. new_test_method = create(TestMethod, name="test_method") new_test_class = create(TestClass, name="TestSomething", test_cases=[new_test_method]) add_test_case_to_project(self.project, new_test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # The right message was issued. assert_contains_once(self._get_log_output(), "Test case TestSomething.test_method already exists in test_module.py, skipping.")
def test_should_emit_warning_when_trying_to_add_test_to_module_with_errors( self): project = EmptyProject() module = project.create_module("module.py") project.create_module("test_module.py", errors=[Exception()]) add_test_case_to_project( project, create(TestClass, name="FooTest", associated_modules=[module])) assert_contains_once( self._get_log_output(), "WARNING: Not adding FooTest to test_module.py, because " "of a failed inspection.")
def test_creates_assertion_for_global_rebind_side_effect(self): call = create(FunctionCall, args={}) new_value = ImmutableObject('new_value') se = GlobalRebind('mod', 'var', new_value) call.add_side_effect(se) put_on_timeline(se, call, call.output) timeline = assertions_for_interaction(call) assert_length(timeline, 4) rebind_assertion = timeline[2] assert_equal(new_value, rebind_assertion.expected) assert_module_variable_reference(rebind_assertion.actual, 'mod', 'var')
def test_replaces_module_instance_in_test_cases_associated_modules_during_module_replacement( self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) test_class = create(TestClass, name='TestAnything', associated_modules=[project[P("other/module.py")]]) add_test_case(project[P("other/module.py")], test_class) new_module = project.create_module(P("other/module.py")) assert_length(test_class.associated_modules, 1) assert test_class.associated_modules[0] is new_module
def test_names_globals_from_submodules_properly(self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod.submod', 'var', old_value) call.add_side_effect(se) put_on_timeline(se, call, call.output) timeline = assertions_for_interaction(call) setup_1, setup_2, teardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 4, [0, 1, 3]) assert_assignment_with_module_variable_reference(setup_1, 'old_mod_submod_var', 'mod.submod', 'var') assert_assignment(setup_2, 'mod.submod.var', old_value) assert_assignment(teardown, 'mod.submod.var', 'old_mod_submod_var')
def test_removes_definitions_of_modules_that_dont_exist_anymore(self): project = ProjectInDirectory(self.tmpdir).with_modules(["module.py", "other_module.py", "test_module.py"]) test_class = create(TestClass, associated_modules=[project["module"]]) add_test_case(project["test_module.py"], test_class) project.save() os.remove(os.path.join(project.path, "other_module.py")) remove_deleted_modules(project) assert_not_raises(ModuleNotFound, lambda: project["module"]) assert_raises(ModuleNotFound, lambda: project["other_module"]) assert_not_raises(ModuleNotFound, lambda: project["test_module"])
def test_doesnt_overwrite_existing_test_methods_by_default(self): test_method = create(TestMethod, name="test_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # Let's try adding the same method again. new_test_method = create(TestMethod, name="test_method") new_test_class = create(TestClass, name="TestSomething", test_cases=[new_test_method]) add_test_case_to_project(self.project, new_test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # The right message was issued. assert_contains_once( self._get_log_output(), "Test case TestSomething.test_method already exists in test_module.py, skipping." )
def test_removes_definitions_of_modules_that_dont_exist_anymore(self): project = ProjectInDirectory(self.tmpdir).with_modules( ["module.py", "other_module.py", "test_module.py"]) test_class = create(TestClass, associated_modules=[project["module"]]) add_test_case(project["test_module.py"], test_class) project.save() os.remove(os.path.join(project.path, "other_module.py")) remove_deleted_modules(project) assert_not_raises(ModuleNotFound, lambda: project["module"]) assert_raises(ModuleNotFound, lambda: project["other_module"]) assert_not_raises(ModuleNotFound, lambda: project["test_module"])
def test_names_globals_from_submodules_properly(self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod.submod', 'var', old_value) call.add_side_effect(se) put_on_timeline(se, call, call.output) timeline = assertions_for_interaction(call) setup_1, setup_2, teardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 4, [0, 1, 3]) assert_assignment_with_module_variable_reference( setup_1, 'old_mod_submod_var', 'mod.submod', 'var') assert_assignment(setup_2, 'mod.submod.var', old_value) assert_assignment(teardown, 'mod.submod.var', 'old_mod_submod_var')
def test_overwrites_existing_test_methods_with_force_option(self): test_method = create(TestMethod, name="test_method") test_class = create(TestClass, name="TestSomething", test_cases=[test_method]) add_test_case_to_project(self.project, test_class) assert_equal([test_method], get_test_cases(self.project)[0].test_cases) # Let's try adding the same method again with a force option # set to True. new_test_method = create(TestMethod, name="test_method") new_test_class = create(TestClass, name="TestSomething", test_cases=[new_test_method]) add_test_case_to_project(self.project, new_test_class, force=True) # The class is still the same. assert_equal([self.existing_test_class], get_test_cases(self.project)) # But the method got replaced. assert_equal([new_test_method], get_test_cases(self.project)[0].test_cases) # The right message was issued. assert_contains_once(self._get_log_output(), "Replacing TestSomething.test_method from test_module.py with generated version.")
def test_creates_only_one_setup_and_teardown_for_multiple_global_read_side_effects_of_the_same_variable(self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod', 'var', old_value) se2 = GlobalRead('mod', 'var', old_value) call.add_side_effect(se) call.add_side_effect(se2) put_on_timeline(se, se2, call, call.output) timeline = assertions_for_interaction(call) setup_1, setup_2, teardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 4, [0, 1, 3]) assert_assignment_with_module_variable_reference(setup_1, 'old_mod_var', 'mod', 'var') assert_assignment(setup_2, 'mod.var', old_value) assert_assignment(teardown, 'mod.var', 'old_mod_var')
def test_creates_only_one_setup_and_teardown_for_multiple_global_read_side_effects_of_the_same_variable( self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod', 'var', old_value) se2 = GlobalRead('mod', 'var', old_value) call.add_side_effect(se) call.add_side_effect(se2) put_on_timeline(se, se2, call, call.output) timeline = assertions_for_interaction(call) setup_1, setup_2, teardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 4, [0, 1, 3]) assert_assignment_with_module_variable_reference( setup_1, 'old_mod_var', 'mod', 'var') assert_assignment(setup_2, 'mod.var', old_value) assert_assignment(teardown, 'mod.var', 'old_mod_var')
def test_creates_setup_and_teardown_for_two_different_global_read_side_effects(self): call = create(FunctionCall, args={}) old_value = ImmutableObject('old_value') se = GlobalRead('mod', 'var', old_value) se2 = GlobalRead('mod', 'other_var', old_value) call.add_side_effect(se) call.add_side_effect(se2) put_on_timeline(se, se2, call, call.output) timeline = assertions_for_interaction(call) varSetup1, varSetup2, varTeardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 7, [2, 3, 5]) assert_assignment_with_module_variable_reference(varSetup1, 'old_mod_var', 'mod', 'var') assert_assignment(varSetup2, 'mod.var', old_value) assert_assignment(varTeardown, 'mod.var', 'old_mod_var') otherVarSetup1, otherVarSetup2, otherVarTeardown = assert_timeline_length_and_return_elements( filter_out_objects(timeline), 7, [0, 1, 6]) assert_assignment_with_module_variable_reference(otherVarSetup1, 'old_mod_other_var', 'mod', 'other_var') assert_assignment(otherVarSetup2, 'mod.other_var', old_value) assert_assignment(otherVarTeardown, 'mod.other_var', 'old_mod_other_var')
def create_parent_call_with_side_effects(call, side_effects): parent_call = create(FunctionCall) parent_call.add_subcall(call) map(parent_call.add_side_effect, side_effects)
def setUp(self): self.alist = create(SequenceObject) self.call = create(FunctionCall, args={}, output=self.alist)
def test_after_adding_new_test_case_to_class_its_module_is_marked_as_changed( self): add_test_case(self.existing_test_class, create(TestMethod, name="test_something_new")) assert self.test_module.changed
def test_generates_side_effect_line_for_builtin_method_call(self): alist = create(SequenceObject) assign = Assign('alist', alist, 1) se = ListAppend(alist, create(ImmutableObject, obj=1)) assert_equal_strings("alist = []\nalist.append(1)\n", generate_test_contents([assign, se], None))
def test_adds_import_for_an_assertion_line(self): aline = EqualAssertionLine(create(SequenceObject), create(FunctionCall), 1) assert_equal(set([('module', 'function')]), generate_test_contents([aline], unittest_template).imports)
def test_generates_assertion_line(self): aline = EqualAssertionLine(create(SequenceObject), create(FunctionCall), 1) assert_equal_strings("self.assertEqual([], function())\n", generate_test_contents([aline], unittest_template))
def test_generates_assignment_line_with_object(self): assign = Assign('foo', create(SequenceObject), 1) assert_equal_strings("foo = []\n", generate_test_contents([assign], None))
def test_doesnt_overwrite_existing_test_classes_by_default(self): test_class = create(TestClass, name="TestSomething") add_test_case_to_project(self.project, test_class) assert_length(get_test_cases(self.project), 1)