示例#1
0
    def test_instance_is_accesible_from_the_moment_it_is_created(self):
        project = EmptyProject()
        mod = Module(project=project, subpath='module.py')
        ct = CodeTree(None)
        project.remember_code_tree(ct, mod)

        assert_equal(ct, CodeTree.of(mod))
示例#2
0
 def _create_project_with_two_points_of_entry(self, *objs):
     project = EmptyProject()
     project.create_module("module.py",
                           code=EmptyCode(),
                           objects=list(objs))
     self.first = PointOfEntry(project, 'first')
     self.second = PointOfEntry(project, 'second')
 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_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
示例#5
0
    def test_removal_of_a_module_removes_its_code_tree(self):
        project = EmptyProject()
        mod = project.create_module('module.py')
        ct = CodeTree(None)
        project.remember_code_tree(ct, mod)

        project.remove_module(mod.subpath)

        assert_raises(CodeTreeNotFound, lambda: CodeTree.of(mod))
 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_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_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
示例#9
0
 def test_raises_module_not_found_exception_when_no_module_like_that_is_present(
         self):
     project = EmptyProject()
     assert_raises(ModuleNotFound, lambda: project["whatever"])
 def setUp(self):
     self.generator = UnittestTestGenerator()
     self.project = EmptyProject()
     self.module = self.project.create_module("module.py")
     self.test_module = self.project.create_module("test_module.py")
 def _inspect_code(self, code):
     return inspect_code(EmptyProject(), "module.py", code)
示例#12
0
 def setUp(self):
     project = EmptyProject()
     self.code = object() # A unique fake object.
     self.module = Module(project=project, subpath='module.py')
     self.code_tree = CodeTree(self.code)
     project.remember_code_tree(self.code_tree, self.module)
示例#13
0
 def setUp(self):
     project = EmptyProject()
     self.module = Module(project=project, subpath='module.py')
     self.klass = Class('Klass', module=self.module)
     self.tclass = TestClass('TClass', parent=self.module)
示例#14
0
 def test_uses_system_specific_path_separator(self):
     module = Module(subpath="some#path.py", project=EmptyProject())
     assert_equal("some.path", module.locator)
示例#15
0
 def setUp(self):
     self.project = EmptyProject()
     self.module = self.project.create_module("module.py", code=parse("# only comments"))
     self.test_class = TestClass(name="TestSomething", code=parse("# some test code"))