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)
Beispiel #2
0
    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_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)
Beispiel #4
0
    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_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
Beispiel #6
0
    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_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)
Beispiel #8
0
    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_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 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_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_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
Beispiel #13
0
    def test_adding_a_test_case_adds_it_to_list_of_objects(self):
        add_test_case(self.module, self.test_class)

        assert_equal([self.test_class], self.module.objects)
Beispiel #14
0
 def test_can_add_test_cases_to_empty_modules(self):
     add_test_case(self.module, self.test_class)
Beispiel #15
0
    def test_adding_a_test_case_adds_it_to_list_of_objects(self):
        add_test_case(self.module, self.test_class)

        assert_equal([self.test_class], self.module.objects)
Beispiel #16
0
 def test_can_add_test_cases_to_empty_modules(self):
     add_test_case(self.module, self.test_class)