예제 #1
0
    def test_inspects_test_modules(self):
        module = self._inspect_code(two_test_classes)

        assert_equal(["unittest"], module.imports)
        assert_equal(["FirstTestClass", "TestMore"], get_names(module.test_classes))
        assert_equal(["test_this", "test_that"], get_names(module.test_classes[0].test_cases))
        assert_equal(["test_more"], get_names(module.test_classes[1].test_cases))
예제 #2
0
    def test_inspects_test_classes_inside_application_modules(self):
        module = self._inspect_code(application_module_with_test_class)

        assert_equal_sets(["os", "unittest"], module.imports)
        assert_equal(application_module_with_test_class, module.get_content())
        assert code_of(module, "main_snippet") is not None
        assert_equal(["TestFib"], get_names(module.test_classes))
        assert_equal(["fib"], get_names(module.functions))
    def test_inspects_test_classes_inside_application_modules(self):
        module = self._inspect_code(application_module_with_test_class)

        assert_equal_sets(["os", "unittest"], module.imports)
        assert_equal(application_module_with_test_class, module.get_content())
        assert code_of(module, 'main_snippet') is not None
        assert_equal(["TestFib"], get_names(module.test_classes))
        assert_equal(["fib"], get_names(module.functions))
    def test_inspects_test_modules(self):
        module = self._inspect_code(two_test_classes)

        assert_equal(["unittest"], module.imports)
        assert_equal(["FirstTestClass", "TestMore"],
                     get_names(module.test_classes))
        assert_equal(["test_this", "test_that"],
                     get_names(module.test_classes[0].test_cases))
        assert_equal(["test_more"],
                     get_names(module.test_classes[1].test_cases))
예제 #5
0
    def test_can_be_saved_and_restored_from_file(self):
        project = ProjectInDirectory(self.tmpdir).with_modules(["good_module.py", "bad_module.py"])
        project['good_module'].add_objects([Class("AClass", [Method("amethod")]),
                                            Function("afunction")])
        project['bad_module'].errors = ["Syntax error"]
        project.save()

        project = Project.from_directory(project.path)

        assert_equal(2, len(project.get_modules()))
        assert_equal(2, len(project['good_module'].objects))
        assert_equal(["AClass"], get_names(project['good_module'].classes))
        assert_equal(["amethod"], get_names(project['good_module'].classes[0].methods))
        assert_equal(["afunction"], get_names(project['good_module'].functions))
        assert_equal(["Syntax error"], project['bad_module'].errors)
예제 #6
0
    def test_can_be_saved_and_restored_from_file(self):
        project = ProjectInDirectory(self.tmpdir).with_modules(
            ["good_module.py", "bad_module.py"])
        project['good_module'].add_objects(
            [Class("AClass", [Method("amethod")]),
             Function("afunction")])
        project['bad_module'].errors = ["Syntax error"]
        project.save()

        project = Project.from_directory(project.path)

        assert_equal(2, len(project.get_modules()))
        assert_equal(2, len(project['good_module'].objects))
        assert_equal(["AClass"], get_names(project['good_module'].classes))
        assert_equal(["amethod"],
                     get_names(project['good_module'].classes[0].methods))
        assert_equal(["afunction"],
                     get_names(project['good_module'].functions))
        assert_equal(["Syntax error"], project['bad_module'].errors)
예제 #7
0
def has_defined_name(module, name):
    # TODO: also look at the list of imports
    return name in get_names(module.objects)
예제 #8
0
    def test_ignores_existance_of_any_inner_class_methods(self):
        module = self._inspect_code(class_with_inner_class)

        assert_single_class(module, "OuterClass")
        assert_equal(["__init__", "outer_class_method"], get_names(module.classes[0].methods))
예제 #9
0
    def test_inspects_methods_of_a_class(self):
        module = self._inspect_code(class_with_methods)

        assert_equal(["first_method", "second_method", "third_method"], get_names(module.classes[0].methods))
예제 #10
0
def has_defined_name(module, name):
    # TODO: also look at the list of imports
    return name in get_names(module.objects)
예제 #11
0
    def test_ignores_existance_of_any_inner_class_methods(self):
        module = self._inspect_code(class_with_inner_class)

        assert_single_class(module, "OuterClass")
        assert_equal(["__init__", "outer_class_method"],
                     get_names(module.classes[0].methods))
예제 #12
0
    def test_inspects_methods_of_a_class(self):
        module = self._inspect_code(class_with_methods)

        assert_equal(["first_method", "second_method", "third_method"],
                     get_names(module.classes[0].methods))