def pythoscope_t3st():
    project = Project.from_directory(".")
    #inspect_project(project)
    #add_tests_to_project(project, modules, template, force)
    #modname = "foo"
    #module = project.create_test_module_from_name(modname)
    #pprint.pprint(module)
    foo = Function("testfoo")

    #module = project.find_module_by_full_path(modname)
    #pprint.pprint(module)
    #pprint.pprint(module.__dict__)
    #pprint.pprint(dir(module))
    #module.objects.append(foo)
    #template = "unittest"
    #generator = pythoscope.generator.TestGenerator.from_template(template)
    #generator._add_tests_for_module(module, project,  True)

    code = test_unparse_ast
    ast2 = ast.parse(inspect.getsource(code))
    code2 = astunparse.unparse(ast2)

    m = project.create_module("tests/foo123.py", code=code2)
    #pprint.pprint(m.__dict__)

    pprint.pprint(project.__dict__)

    for module in project.get_modules():
        module.changed = True
        #     print("Calling save() on module %r" % module.subpath)
    #     module.save()

    project.save()
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
def ProjectInDirectory(project_path):
    putdir(project_path, ".pythoscope")
    putdir(project_path, P(".pythoscope/code-trees"))
    project = Project(project_path)
    return project
Esempio n. 5
0
def EmptyProject():
    project = Project(path=os.path.realpath("."),
                      code_trees_manager_class=MemoryCodeTreesManager)
    # Preserve the default value.
    project.new_tests_directory = "tests"
    return project
Esempio n. 6
0
 def __init__(self, project=None, name="poe", content=""):
     if project is None:
         project = Project('.')
     PointOfEntry.__init__(self, project, name)
     self.content = content
Esempio n. 7
0
 def find_object(self, type, name, modulename=None):
     if self._all_catch_module is not None:
         return self._all_catch_module.find_object(type, name)
     return Project.find_object(self, type, name, modulename)
Esempio n. 8
0
 def __init__(self, path=os.path.realpath(".")):
     Project.__init__(self,
                      path=path,
                      code_trees_manager_class=MemoryCodeTreesManager)
     self._last_module = None
     self._all_catch_module = None
Esempio n. 9
0
 def find_object(self, type, name, modulename=None):
     if self._all_catch_module is not None:
         return self._all_catch_module.find_object(type, name)
     return Project.find_object(self, type, name, modulename)
Esempio n. 10
0
 def __init__(self, path=os.path.realpath(".")):
     Project.__init__(self, path=path,
         code_trees_manager_class=MemoryCodeTreesManager)
     self._last_module = None
     self._all_catch_module = None
Esempio n. 11
0
 def _test_finds_new_test_directory(self, test_module_dir):
     putdir(self.tmpdir, ".pythoscope")
     putdir(self.tmpdir, test_module_dir)
     project = Project(self.tmpdir)
     assert_equal(test_module_dir, project.new_tests_directory)