Commits

Anonymous committed ee90187

Not using deprecated PyCore.create_module and create_package

Comments (0)

Files changed (17)

ropetest/advanced_oi_test.py

         super(DynamicOITest, self).tearDown()
 
     def test_simple_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func(a_func)\n'
         mod.write(code)
                           pymod.get_attribute('a_var').get_object())
 
     def test_module_dti(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         code = 'import mod1\ndef a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func(mod1)\n'
         mod2.write(code)
                           pymod2.get_attribute('a_var').get_object())
 
     def test_class_from_another_module_dti(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         code1 = 'class AClass(object):\n    pass\n'
         code2 = 'from mod1 import AClass\n' \
                '\ndef a_func(arg):\n    return eval("arg")\n' \
 
 
     def test_class_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class AClass(object):\n    pass\n' \
                '\ndef a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func(AClass)\n'
                           pymod.get_attribute('a_var').get_object())
 
     def test_instance_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class AClass(object):\n    pass\n' \
                '\ndef a_func(arg):\n    return eval("arg()")\n' \
                'a_var = a_func(AClass)\n'
                           pymod.get_attribute('a_var').get_object().get_type())
 
     def test_method_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class AClass(object):\n    def a_method(self, arg):\n        return eval("arg()")\n' \
                'an_instance = AClass()\n' \
                'a_var = an_instance.a_method(AClass)\n'
                           pymod.get_attribute('a_var').get_object().get_type())
 
     def test_function_argument_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    pass\n' \
                'a_func(a_func)\n'
         mod.write(code)
                           pyscope.get_scopes()[0].get_name('arg').get_object())
 
     def test_classes_with_the_same_name(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    class AClass(object):\n        pass\n    return eval("arg")\n' \
                'class AClass(object):\n    pass\n' \
                'a_var = a_func(AClass)\n'
                           pymod.get_attribute('a_var').get_object())
 
     def test_nested_classes(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func():\n    class AClass(object):\n        pass\n    return AClass\n' \
                'def another_func(arg):\n    return eval("arg")\n' \
                'a_var = another_func(a_func())\n'
                           pyscope.get_name('a_var').get_object())
 
     def test_function_argument_dti2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg, a_builtin_type):\n    pass\n' \
                'a_func(a_func, [])\n'
         mod.write(code)
                           pyscope.get_scopes()[0].get_name('arg').get_object())
 
     def test_dti_and_concluded_data_invalidation(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func(a_func)\n'
         mod.write(code)
                           pymod.get_attribute('a_var').get_object())
 
     def test_list_objects_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func([C()])[0]\n'
         mod.write(code)
         self.assertEquals(c_class, a_var.get_type())
 
     def test_for_loops_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
                'for c in a_func([C()]):\n    a_var = c\n'
         mod.write(code)
         self.assertEquals(c_class, a_var.get_type())
 
     def test_dict_objects_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C(object):\n    pass\n' \
                'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func({1: C()})[1]\n'
         self.assertEquals(c_class, a_var.get_type())
 
     def test_dict_keys_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C(object):\n    pass\n' \
                'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func({C(): 1}).keys()[0]\n'
         self.assertEquals(c_class, a_var.get_type())
 
     def test_dict_keys_and_dynamicoi2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(arg):\n    return eval("arg")\n' \
                'a, b = a_func((C1(), C2()))\n'
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_strs_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func("hey")\n'
         mod.write(code)
         self.assertTrue(isinstance(a_var.get_type(), rope.base.builtins.Str))
 
     def test_textual_transformations(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C(object):\n    pass\ndef f():\n    pass\na_var = C()\n' \
                'a_list = [C()]\na_str = "hey"\na_file = open("file.txt")\n'
         mod.write(code)
                           complex_to_textual(enumerate_func))
 
     def test_arguments_with_keywords(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(arg):\n    return eval("arg")\n' \
                'a = a_func(arg=C1())\nb = a_func(arg=C2())\n'
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_a_function_with_different_returns(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(arg):\n    return eval("arg")\n' \
                'a = a_func(C1())\nb = a_func(C2())\n'
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_a_function_with_different_returns2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(p):\n    if p == C1:\n        return C1()\n' \
                '    else:\n        return C2()\n' \
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_ignoring_star_args(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(p, *args):\n    if p == C1:\n        return C1()\n' \
                '    else:\n        return C2()\n' \
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_ignoring_double_star_args(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
                'def a_func(p, *kwds, **args):\n    if p == C1:\n        return C1()\n' \
                '    else:\n        return C2()\n' \
         self.assertEquals(c2_class, b_var.get_type())
 
     def test_invalidating_data_after_changing(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'def a_func(arg):\n    return eval("arg")\n' \
                'a_var = a_func(a_func)\n'
         mod.write(code)
                              pymod.get_attribute('a_var').get_object())
 
     def test_invalidating_data_after_moving(self):
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('class C(object):\n    pass\n')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         code = 'import mod2\ndef a_func(arg):\n    return eval(arg)\n' \
                'a_var = a_func("mod2.C")\n'
         mod.write(code)
         super(NewStaticOITest, self).setUp()
         self.project = testutils.sample_project(validate_objectdb=True)
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)
         self.assertEquals(c2_class, a_var.get_type())
 
     def test_invalidating_concluded_data_in_a_function(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('def func(arg):\n    temp = arg\n    return temp\n')
         mod2.write('import mod1\n'
                    'class C1(object):\n    pass\n'
         self.assertEquals(c1_class, a_var.get_type())
 
     def test_not_saving_unknown_function_returns(self):
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         self.mod.write('class C(object):\n    pass\nl = []\nl.append(C())\n')
         mod2.write('import mod\ndef f():\n    return mod.l.pop()\na_var = f()\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         self.assertEquals(c_class, p_type)
 
     def test_validation_problems_for_objectdb_retrievals(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('l = []\nvar = l.pop()\n')
         mod2.write('import mod1\n\nclass C(object):\n    pass\n'
                    'mod1.l.append(C())\n')

ropetest/builtintest.py

         super(BuiltinTypesTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/codeanalyzetest.py

 
     def test_modules_after_from_statements(self):
         root_folder = self.project.root
-        mod = self.pycore.create_module(root_folder, 'mod')
+        mod = testutils.create_module(self.project, 'mod', root_folder)
         mod.write('def a_func():\n    pass\n')
         code = 'from mod import a_func\n'
         scope = self.pycore.get_string_scope(code)
 
     @testutils.run_only_for_25
     def test_relative_modules_after_from_statements(self):
-        pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = self.pycore.create_package(pkg1, 'pkg2')
-        mod1 = self.pycore.create_module(pkg1, 'mod1')
-        mod2 = self.pycore.create_module(pkg2, 'mod2')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        mod1 = testutils.create_module(self.project, 'mod1', pkg1)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg2)
         mod1.write('def a_func():\n    pass\n')
         code = 'from ..mod1 import a_func\n'
         mod2.write(code)
         self.assertEquals(mod1_pyobject, found_pyname.get_object())
 
     def test_relative_modules_after_from_statements2(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = self.pycore.create_package(pkg1, 'pkg2')
-        mod2 = self.pycore.create_module(pkg2, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg2)
         mod1.write('import pkg1.pkg2.mod2')
 
         mod1_scope = self.pycore.resource_to_pyobject(mod1).get_scope()

ropetest/contrib/codeassisttest.py

         self.assertEquals((None, 2), result)
 
     def test_get_definition_location_dotted_module_names(self):
-        module_resource = self.project.get_pycore().\
-                          create_module(self.project.root, 'mod')
+        module_resource = testutils.create_module(self.project, 'mod')
         module_resource.write('def a_func():\n    pass\n')
         code = 'import mod\nmod.a_func()'
         result = get_definition_location(self.project, code, len(code) - 3)
 
     def test_get_definition_location_for_nested_packages(self):
         pycore = self.project.get_pycore()
-        mod1 = pycore.create_module(self.project.root, 'mod1')
-        pkg1 = pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = pycore.create_package(pkg1, 'pkg2')
-        mod2 = pycore.create_module(pkg2, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg2)
         mod1.write('import pkg1.pkg2.mod2')
 
         mod1_scope = pycore.resource_to_pyobject(mod1).get_scope()
 
     def test_get_pydoc_for_modules(self):
         pycore = self.project.get_pycore()
-        mod = pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('"""a module"""\n')
         src = 'import mod\nmod'
         self.assertEquals('a module', get_doc(self.project, src, len(src) - 1))
         super(CodeAssistInProjectsTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        samplemod = self.pycore.create_module(self.project.root, 'samplemod')
+        samplemod = testutils.create_module(self.project, 'samplemod')
         samplemod.write("class SampleClass(object):\n    def sample_method():\n        pass" + \
                         "\n\ndef sample_func():\n    pass\nsample_var = 10\n" + \
                         "\ndef _underlined_func():\n    pass\n\n")
-        package = self.pycore.create_package(self.project.root, 'package')
-        nestedmod = self.pycore.create_module(package, 'nestedmod')
+        package = testutils.create_package(self.project, 'package')
+        nestedmod = testutils.create_module(self.project, 'nestedmod', package)
 
     def tearDown(self):
         testutils.remove_project(self.project)
         self.assert_completion_not_in_result('Sample', 'global', result)
 
     def test_assist_on_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod1.write('def a_func():\n    pass\n')
         code = 'import mod1\nmod1.'
         result = self._assist(code, resource=mod2)
         self.assert_completion_in_result('a_func', 'attribute', result)
 
     def test_get_location_on_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod1.write('def a_func():\n    pass\n')
         code = 'import mod1\nmod1.a_func\n'
         result = get_definition_location(self.project, code,
         self.assertEquals((mod1, 1), result)
 
     def test_get_doc_on_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod1.write('def a_func():\n    """hey"""\n    pass\n')
         code = 'import mod1\nmod1.a_func\n'
         result = get_doc(self.project, code, len(code) - 2, mod2)
         self.assertTrue(result.endswith('hey'))
 
     def test_finding_occurrences(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('a_var = 1\n')
         result = find_occurrences(self.project, mod, 1)
         self.assertEquals(mod, result[0].resource)
         self.assertEquals(False, result[0].unsure)
 
     def test_finding_occurrences_in_more_than_one_module(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('a_var = 1\n')
         mod2.write('import mod1\nmy_var = mod1.a_var')
         result = find_occurrences(self.project, mod1, 1)
         self.assertTrue(mod1 in modules and mod2 in modules)
 
     def test_finding_occurrences_matching_when_unsure(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('class C(object):\n    def a_func(self):\n        pass\n'
                    'def f(arg):\n    arg.a_func()\n')
         result = find_occurrences(

ropetest/contrib/generatetest.py

         super(GenerateTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod1')
-        self.mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        self.pkg = self.pycore.create_package(self.project.root, 'pkg')
+        self.mod = testutils.create_module(self.project, 'mod1')
+        self.mod2 = testutils.create_module(self.project, 'mod2')
+        self.pkg = testutils.create_package(self.project, 'pkg')
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/objectinfertest.py

         self.assertEquals(c_class, a_var.get_type())
 
     def test_handling_generator_functions_for_strs(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('def f():\n    yield ""\n'
                   'for s in f():\n    a_var = s\n')
         pymod = self.pycore.resource_to_pyobject(mod)

ropetest/projecttest.py

         self.project = testutils.sample_project(ropefolder=None,
                                                 ignore_syntax_errors=True)
         pycore = self.project.pycore
-        mod = pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('xyz print')
         pymod = pycore.resource_to_pyobject(mod)
 

ropetest/pycoretest.py

         super(PyCoreTest, self).tearDown()
 
     def test_simple_module(self):
-        self.pycore.create_module(self.project.root, 'mod')
+        testutils.create_module(self.project, 'mod')
         result = self.pycore.get_module('mod')
         self.assertEquals(get_base_type('Module'), result.type)
         self.assertEquals(0, len(result.get_attributes()))
 
     def test_nested_modules(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod = self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod = testutils.create_module(self.project, 'mod', pkg)
         package = self.pycore.get_module('pkg')
         self.assertEquals(get_base_type('Module'), package.get_type())
         self.assertEquals(1, len(package.get_attributes()))
         self.assertEquals(get_base_type('Module'), module.get_type())
 
     def test_package(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod = self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod = testutils.create_module(self.project, 'mod', pkg)
         result = self.pycore.get_module('pkg')
         self.assertEquals(get_base_type('Module'), result.type)
 
     def test_simple_class(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    pass\n')
         mod_element = self.pycore.get_module('mod')
         result = mod_element.get_attribute('SampleClass').get_object()
         self.assertEquals(get_base_type('Type'), result.get_type())
 
     def test_simple_function(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('def sample_function():\n    pass\n')
         mod_element = self.pycore.get_module('mod')
         result = mod_element.get_attribute('sample_function').get_object()
         self.assertEquals(get_base_type('Function'), result.get_type())
 
     def test_class_methods(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    def sample_method(self):\n        pass\n')
         mod_element = self.pycore.get_module('mod')
         sample_class = mod_element.get_attribute('SampleClass').get_object()
         self.assertEquals(get_base_type('Function'), method.get_type())
 
     def test_global_variables(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('var = 10')
         mod_element = self.pycore.get_module('mod')
         result = mod_element.get_attribute('var')
 
     def test_class_variables(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    var = 10\n')
         mod_element = self.pycore.get_module('mod')
         sample_class = mod_element.get_attribute('SampleClass').get_object()
         var = sample_class.get_attribute('var')
 
     def test_class_attributes_set_in_init(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    def __init__(self):\n        self.var = 20\n')
         mod_element = self.pycore.get_module('mod')
         sample_class = mod_element.get_attribute('SampleClass').get_object()
         var = sample_class.get_attribute('var')
 
     def test_classes_inside_other_classes(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    class InnerClass(object):\n        pass\n\n')
         mod_element = self.pycore.get_module('mod')
         sample_class = mod_element.get_attribute('SampleClass').get_object()
         self.pycore.get_module('doesnotexistmodule')
 
     def test_imported_names(self):
-        self.pycore.create_module(self.project.root, 'mod1')
-        mod = self.pycore.create_module(self.project.root, 'mod2')
+        testutils.create_module(self.project, 'mod1')
+        mod = testutils.create_module(self.project, 'mod2')
         mod.write('import mod1\n')
         module = self.pycore.get_module('mod2')
         imported_sys = module.get_attribute('mod1').get_object()
         self.assertEquals(get_base_type('Module'), imported_sys.get_type())
 
     def test_imported_as_names(self):
-        self.pycore.create_module(self.project.root, 'mod1')
-        mod = self.pycore.create_module(self.project.root, 'mod2')
+        testutils.create_module(self.project, 'mod1')
+        mod = testutils.create_module(self.project, 'mod2')
         mod.write('import mod1 as my_import\n')
         module = self.pycore.get_module('mod2')
         imported_mod = module.get_attribute('my_import').get_object()
         self.assertTrue('f' in derived.get_attributes())
 
     def test_module_creation(self):
-        new_module = self.pycore.create_module(self.project.root, 'module')
+        new_module = testutils.create_module(self.project, 'module')
         self.assertFalse(new_module.is_folder())
         self.assertEquals(self.project.get_resource('module.py'), new_module)
 
     def test_packaged_module_creation(self):
         package = self.project.root.create_folder('package')
-        new_module = self.pycore.create_module(self.project.root, 'package.module')
+        new_module = testutils.create_module(self.project, 'package.module')
         self.assertEquals(self.project.get_resource('package/module.py'), new_module)
 
     def test_packaged_module_creation_with_nested_src(self):
         src = self.project.root.create_folder('src')
         package = src.create_folder('pkg')
-        new_module = self.pycore.create_module(src, 'pkg.mod')
+        new_module = testutils.create_module(self.project, 'pkg.mod', src)
         self.assertEquals(self.project.get_resource('src/pkg/mod.py'), new_module)
 
     def test_package_creation(self):
-        new_package = self.pycore.create_package(self.project.root, 'pkg')
+        new_package = testutils.create_package(self.project, 'pkg')
         self.assertTrue(new_package.is_folder())
         self.assertEquals(self.project.get_resource('pkg'), new_package)
         self.assertEquals(self.project.get_resource('pkg/__init__.py'),
                           new_package.get_child('__init__.py'));
 
     def test_nested_package_creation(self):
-        package = self.pycore.create_package(self.project.root, 'pkg1')
-        nested_package = self.pycore.create_package(self.project.root, 'pkg1.pkg2')
+        package = testutils.create_package(self.project, 'pkg1')
+        nested_package = testutils.create_package(self.project, 'pkg1.pkg2')
         self.assertEquals(self.project.get_resource('pkg1/pkg2'), nested_package)
 
     def test_packaged_package_creation_with_nested_src(self):
         src = self.project.root.create_folder('src')
-        package = self.pycore.create_package(src, 'pkg1')
-        nested_package = self.pycore.create_package(src, 'pkg1.pkg2')
+        package = testutils.create_package(self.project, 'pkg1', src)
+        nested_package = testutils.create_package(self.project, 'pkg1.pkg2', src)
         self.assertEquals(self.project.get_resource('src/pkg1/pkg2'), nested_package)
 
     def test_find_module(self):
         src = self.project.root.create_folder('src')
-        samplemod = self.pycore.create_module(src, 'samplemod')
+        samplemod = testutils.create_module(self.project, 'samplemod', src)
         found_module = self.pycore.find_module('samplemod')
         self.assertEquals(samplemod, found_module)
 
     def test_find_nested_module(self):
         src = self.project.root.create_folder('src')
-        samplepkg = self.pycore.create_package(src, 'samplepkg')
-        samplemod = self.pycore.create_module(samplepkg, 'samplemod')
+        samplepkg = testutils.create_package(self.project, 'samplepkg', src)
+        samplemod = testutils.create_module(self.project, 'samplemod', samplepkg)
         found_module = self.pycore.find_module('samplepkg.samplemod')
         self.assertEquals(samplemod, found_module)
 
     def test_find_multiple_module(self):
         src = self.project.root.create_folder('src')
-        samplemod1 = self.pycore.create_module(src, 'samplemod')
-        samplemod2 = self.pycore.create_module(self.project.root, 'samplemod')
+        samplemod1 = testutils.create_module(self.project, 'samplemod', src)
+        samplemod2 = testutils.create_module(self.project, 'samplemod')
         test = self.project.root.create_folder('test')
-        samplemod3 = self.pycore.create_module(test, 'samplemod')
+        samplemod3 = testutils.create_module(self.project, 'samplemod', test)
         found_module = self.pycore.find_module('samplemod')
         self.assertTrue(samplemod1 == found_module or
                         samplemod2 == found_module or
 
     def test_find_module_packages(self):
         src = self.project.root
-        samplepkg = self.pycore.create_package(src, 'samplepkg')
+        samplepkg = testutils.create_package(self.project, 'samplepkg', src)
         found_module = self.pycore.find_module('samplepkg')
         self.assertEquals(samplepkg, found_module)
 
     def test_find_module_when_module_and_package_with_the_same_name(self):
         src = self.project.root
-        samplemod = self.pycore.create_module(src, 'sample')
-        samplepkg = self.pycore.create_package(src, 'sample')
+        samplemod = testutils.create_module(self.project, 'sample', src)
+        samplepkg = testutils.create_package(self.project, 'sample', src)
         found_module = self.pycore.find_module('sample')
         self.assertEquals(samplepkg, found_module)
 
         self.assertTrue(test in source_folders)
 
     def test_multi_source_folders2(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         src = self.project.root.create_folder('src')
-        package = self.pycore.create_package(src, 'package')
-        mod2 = self.pycore.create_module(package, 'mod2')
+        package = testutils.create_package(self.project, 'package', src)
+        mod2 = testutils.create_module(self.project, 'mod2', package)
         source_folders = self.pycore.get_source_folders()
         self.assertEquals(2, len(source_folders))
         self.assertTrue(self.project.root in source_folders and \
         self.assertEquals((mod, 1), a_var.get_definition_location())
 
     def test_get_pyname_definition_location_importes(self):
-        module = self.pycore.create_module(self.project.root, 'mod')
+        module = testutils.create_module(self.project, 'mod')
         mod = self.pycore.get_string_module('import mod\n')
         imported_module = self.pycore.get_module('mod')
         module_pyname = mod.get_attribute('mod')
                           module_pyname.get_definition_location())
 
     def test_get_pyname_definition_location_imports(self):
-        module_resource = self.pycore.create_module(self.project.root, 'mod')
+        module_resource = testutils.create_module(self.project, 'mod')
         module_resource.write('\ndef a_func():\n    pass\n')
         imported_module = self.pycore.get_module('mod')
         mod = self.pycore.get_string_module('from mod import a_func\n')
         self.assertEquals((mod, 1), param2.get_definition_location())
 
     def test_module_get_resource(self):
-        module_resource = self.pycore.create_module(self.project.root, 'mod')
+        module_resource = testutils.create_module(self.project, 'mod')
         module = self.pycore.get_module('mod')
         self.assertEquals(module_resource, module.get_resource())
         string_module = self.pycore.get_string_module('from mod import a_func\n')
         self.assertEquals((None, None), sample.get_definition_location())
 
     def test_from_package_import_module_get_definition_location(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        testutils.create_module(self.project, 'mod', pkg)
         pkg_mod = self.pycore.get_module('pkg.mod')
         mod = self.pycore.get_string_module('from pkg import mod\n')
         imported_mod = mod.get_attribute('mod')
         self.assertEquals(mod, a_class.get_module())
 
     def test_get_definition_location_for_packages(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        pkg = testutils.create_package(self.project, 'pkg')
         init_module = self.pycore.get_module('pkg.__init__')
         mod = self.pycore.get_string_module('import pkg\n')
         pkg_pyname = mod.get_attribute('pkg')
         self.assertEquals((init_module, 1), pkg_pyname.get_definition_location())
 
     def test_get_definition_location_for_filtered_packages(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        testutils.create_module(self.project, 'mod', pkg)
         init_module = self.pycore.get_module('pkg.__init__')
         mod = self.pycore.get_string_module('import pkg.mod')
         pkg_pyname = mod.get_attribute('pkg')
 
     def test_file_encoding_reading(self):
         contents = u'# -*- coding: utf-8 -*-\n#\N{LATIN SMALL LETTER I WITH DIAERESIS}\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(contents)
         self.pycore.get_module('mod')
 
         self.assertEquals(global_var, local_var)
 
     def test_not_leaking_for_vars_inside_parent_scope(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class C(object):\n    def f(self):\n'
                   '        for my_var1, my_var2 in []:\n            pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertFalse('my_var2' in c_class.get_attributes())
 
     def test_not_leaking_for_vars_inside_parent_scope2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class C(object):\n    def f(self):\n'
                   '        for my_var in []:\n            pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertFalse('my_var' in c_class.get_attributes())
 
     def test_not_leaking_tuple_assigned_names_inside_parent_scope(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class C(object):\n    def f(self):\n'
                   '        var1, var2 = range(2)\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         super(self.__class__, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        samplemod = self.pycore.create_module(self.project.root, 'samplemod')
+        samplemod = testutils.create_module(self.project, 'samplemod')
         samplemod.write("class SampleClass(object):\n    def sample_method():\n        pass" + \
                         "\n\ndef sample_func():\n    pass\nsample_var = 10\n" + \
                         "\ndef _underlined_func():\n    pass\n\n")
-        package = self.pycore.create_package(self.project.root, 'package')
-        nestedmod = self.pycore.create_module(package, 'nestedmod')
+        package = testutils.create_package(self.project, 'package')
+        nestedmod = testutils.create_module(self.project, 'nestedmod', package)
 
     def tearDown(self):
         testutils.remove_project(self.project)
                           get_object().get_type())
 
     def test_circular_imports(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('import mod2\n')
         mod2.write('import mod1\n')
         module1 = self.pycore.get_module('mod1')
 
     def test_circular_imports2(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('from mod2 import Sample2\nclass Sample1(object):\n    pass\n')
         mod2.write('from mod1 import Sample1\nclass Sample2(object):\n    pass\n')
         module1 = self.pycore.get_module('mod1').get_attributes()
 
     def test_multi_dot_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        pkg_mod = self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        pkg_mod = testutils.create_module(self.project, 'mod', pkg)
         pkg_mod.write('def sample_func():\n    pass\n')
         mod = self.pycore.get_string_module('import pkg.mod\n')
         self.assertTrue('pkg' in mod.get_attributes())
                         get_object().get_attributes())
 
     def test_multi_dot_imports2(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod = self.pycore.get_string_module('import pkg.mod1\nimport pkg.mod2\n')
         package = mod.get_attribute('pkg').get_object()
         self.assertEquals(2, len(package.get_attributes()))
                         'mod2' in package.get_attributes())
 
     def test_multi_dot_imports3(self):
-        pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = self.pycore.create_package(pkg1, 'pkg2')
-        mod1 = self.pycore.create_module(pkg2, 'mod1')
-        mod2 = self.pycore.create_module(pkg2, 'mod2')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        mod1 = testutils.create_module(self.project, 'mod1', pkg2)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg2)
         mod = self.pycore.get_string_module('import pkg1.pkg2.mod1\nimport pkg1.pkg2.mod2\n')
         package1 = mod.get_attribute('pkg1').get_object()
         package2 = package1.get_attribute('pkg2').get_object()
                         'mod2' in package2.get_attributes())
 
     def test_multi_dot_imports_as(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
         mod1.write('def f():\n    pass\n')
         mod = self.pycore.get_string_module('import pkg.mod1 as mod1\n')
         module = mod.get_attribute('mod1').get_object()
 
     # TODO: not showing unimported names as attributes of packages
     def xxx_test_from_package_import_package(self):
-        pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = self.pycore.create_package(pkg1, 'pkg2')
-        module = self.pycore.create_module(pkg2, 'mod')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        module = testutils.create_module(self.project, 'mod', pkg2)
         mod = self.pycore.get_string_module('from pkg1 import pkg2\n')
         package = mod.get_attribute('pkg2')
         self.assertEquals(0, len(package.get_attributes()))
 
     def test_invalidating_cache_after_resource_change(self):
-        module = self.pycore.create_module(self.project.root, 'mod')
+        module = testutils.create_module(self.project, 'mod')
         module.write('import sys\n')
         mod1 = self.pycore.get_module('mod')
         self.assertTrue('var' not in mod1.get_attributes())
         self.assertTrue('var' in mod2.get_attributes())
 
     def test_invalidating_cache_after_resource_change_for_init_dot_pys(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod = testutils.create_module(self.project, 'mod')
         init_dot_py = pkg.get_child('__init__.py')
         init_dot_py.write('a_var = 10\n')
         mod.write('import pkg\n')
         self.assertTrue('a_var' not in pymod.get_attribute('pkg').get_object().get_attributes())
 
     def test_invalidating_cache_after_resource_change_for_nested_init_dot_pys(self):
-        pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        pkg2 = self.pycore.create_package(pkg1, 'pkg2')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        pkg1 = testutils.create_package(self.project, 'pkg1')
+        pkg2 = testutils.create_package(self.project, 'pkg2', pkg1)
+        mod = testutils.create_module(self.project, 'mod')
         init_dot_py = pkg2.get_child('__init__.py')
         init_dot_py.write('a_var = 10\n')
         mod.write('import pkg1\n')
                              func_scope.get_name('self').get_object().get_type())
 
     def test_location_of_imports_when_importing(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('from samplemod import SampleClass\n')
         scope = self.pycore.get_string_scope('from mod import SampleClass\n')
         sample_class = scope.get_name('SampleClass')
         self.assertEquals((samplemod, 1), sample_class.get_definition_location())
 
     def test_nested_modules(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod = self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod = testutils.create_module(self.project, 'mod', pkg)
         imported_module = self.pycore.get_module('pkg.mod')
         scope = self.pycore.get_string_scope('import pkg.mod\n')
         mod_pyobject = scope.get_name('pkg').get_object().get_attribute('mod')
                           mod_pyobject.get_definition_location())
 
     def test_reading_init_dot_py(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        pkg = testutils.create_package(self.project, 'pkg')
         init_dot_py = pkg.get_child('__init__.py')
         init_dot_py.write('a_var = 1\n')
         pkg_object = self.pycore.get_module('pkg')
         self.assertTrue('a_var' in pkg_object.get_attributes())
 
     def test_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
         self.assertEquals(mod1_object, mod2_object.get_attributes()['mod1'].get_object())
 
     def test_relative_froms(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod1.write('def a_func():\n    pass\n')
         mod2.write('from mod1 import a_func\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
                           mod2_object.get_attribute('a_func').get_object())
 
     def test_relative_imports_for_string_modules(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.get_string_module(mod2.read(), mod2)
         self.assertEquals(mod1_object, mod2_object.get_attribute('mod1').get_object())
 
     def test_relative_imports_for_string_scopes(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_scope = self.pycore.get_string_scope(mod2.read(), mod2)
 
     @testutils.run_only_for_25
     def test_new_style_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('from . import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
 
     @testutils.run_only_for_25
     def test_new_style_relative_imports2(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod1.write('def a_func():\n    pass\n')
         mod2.write('from ..mod1 import a_func\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
                           mod2_object.get_attribute('a_func').get_object())
 
     def test_invalidating_cache_for_from_imports_after_resource_change(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('def a_func():\n    print(1)\n')
         mod1.write('from mod2 import a_func\na_func()\n')
 
                           pymod2.get_attribute('a_func').get_object())
 
     def test_invalidating_superclasses_after_change(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class A(object):\n    def func1(self):\n        pass\n')
         mod2.write('import mod1\nclass B(mod1.A):\n    pass\n')
 
         self.assertTrue('func2' in b_class.get_attributes())
 
     def test_simple_module(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertTrue(pymod.is_valid())
         mod.write('a = 1\n')
         self.assertEquals([a_class, b_class], c_class.get_superclasses())
 
     def test_empty_get_subclasses(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class A(object):\n    pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         a_class = pymod.get_attribute('A')
         self.assertEquals([], self.pycore.get_subclasses(a_class))
 
     def test_get_subclasses(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class A(object):\n    pass\n\n'
                   'class B(A):\n    pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertEquals([b_class], self.pycore.get_subclasses(a_class))
 
     def test_get_subclasses_in_multiple_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class A(object):\n    pass\n')
         mod2.write('import mod1\nclass B(mod1.A):\n    pass\n')
         pymod1 = self.pycore.resource_to_pyobject(mod1)
         self.assertEquals([b_class], self.pycore.get_subclasses(a_class))
 
     def test_get_subclasses_reversed(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class B(A):\n    pass\n'
                   'class A(object):\n    pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertEquals([b_class], self.pycore.get_subclasses(a_class))
 
     def test_get_subclasses_for_in_string_definitions(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('"""\nclass B(A):\n    pass\n"""\n'
                   'class A(object):\n    pass\n')
         pymod = self.pycore.resource_to_pyobject(mod)
         self.assertEquals([], self.pycore.get_subclasses(a_class))
 
     def test_get_classes_for_in_string_definitions(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class A(object):\n    pass\n')
         self.assertEquals(1, len(self.pycore.get_classes()))
         mod.write('')

ropetest/refactor/__init__.py

         super(MethodObjectTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)
 
     def test_adding_the_method(self):
         code = 'class AClass(object):\n    an_attr = 10\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    an_attr = 10\n\n' \
                    '    @staticmethod\n    def create(*args, **kwds):\n' \
 
     def test_changing_occurances_in_the_main_module(self):
         code = 'class AClass(object):\n    an_attr = 10\na_var = AClass()'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    an_attr = 10\n\n' \
                    '    @staticmethod\n    def create(*args, **kwds):\n' \
     def test_changing_occurances_with_arguments(self):
         code = 'class AClass(object):\n    def __init__(self, arg):\n        pass\n' \
                'a_var = AClass(10)\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    def __init__(self, arg):\n        pass\n\n' \
                    '    @staticmethod\n    def create(*args, **kwds):\n' \
         self.assertEquals(expected, mod.read())
 
     def test_changing_occurances_in_other_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class AClass(object):\n    an_attr = 10\n')
         mod2.write('import mod1\na_var = mod1.AClass()\n')
         self._introduce_factory(mod1, mod1.read().index('AClass') + 1, 'create')
 
     @testutils.assert_raises(RefactoringError)
     def test_raising_exception_for_non_classes(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('def a_func():\n    pass\n')
         self._introduce_factory(mod, mod.read().index('a_func') + 1, 'create')
 
     def test_undoing_introduce_factory(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         code1 = 'class AClass(object):\n    an_attr = 10\n'
         mod1.write(code1)
         code2 = 'from mod1 import AClass\na_var = AClass()\n'
         self.assertEquals(code2, mod2.read())
 
     def test_using_on_an_occurance_outside_the_main_module(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class AClass(object):\n    an_attr = 10\n')
         mod2.write('import mod1\na_var = mod1.AClass()\n')
         self._introduce_factory(mod2, mod2.read().index('AClass') + 1, 'create')
                '    class AClass(object):\n'\
                '        an_attr = 10\n'\
                '    return AClass()\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'def create_var():\n'\
                    '    class AClass(object):\n'\
 
     def test_adding_factory_for_global_factories(self):
         code = 'class AClass(object):\n    an_attr = 10\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    an_attr = 10\n\n' \
                    'def create(*args, **kwds):\n' \
                '    class AClass(object):\n'\
                '        an_attr = 10\n'\
                '    return AClass()\n'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         self._introduce_factory(mod, mod.read().index('AClass') + 1,
                                            'create', global_factory=True)
 
     def test_changing_occurances_in_the_main_module_for_global_factories(self):
         code = 'class AClass(object):\n    an_attr = 10\na_var = AClass()'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    an_attr = 10\n\n' \
                    'def create(*args, **kwds):\n' \
         self.assertEquals(expected, mod.read())
 
     def test_changing_occurances_in_other_modules_for_global_factories(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class AClass(object):\n    an_attr = 10\n')
         mod2.write('import mod1\na_var = mod1.AClass()\n')
         self._introduce_factory(mod1, mod1.read().index('AClass') + 1,
         self.assertEquals(expected2, mod2.read())
 
     def test_importing_if_necessary_in_other_modules_for_global_factories(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('class AClass(object):\n    an_attr = 10\n')
         mod2.write('from mod1 import AClass\npair = AClass(), AClass\n')
         self._introduce_factory(mod1, mod1.read().index('AClass') + 1,
     # XXX: Should we replace `a_class` here with `AClass.create` too
     def test_changing_occurances_for_renamed_classes(self):
         code = 'class AClass(object):\n    an_attr = 10\na_class = AClass\na_var = a_class()'
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write(code)
         expected = 'class AClass(object):\n    an_attr = 10\n\n' \
                    '    @staticmethod\n    def create(*args, **kwds):\n' \
         self.assertEquals(expected, mod.read())
 
     def test_changing_occurrences_in_the_same_module_with_conflicting_ranges(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('class C(object):\n'
                   '    def create(self):\n        return C()\n')
         self._introduce_factory(mod, mod.read().index('C'), 'create_c', True)
                         self.project, resource).get_changes())
 
     def test_transform_module_to_package(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('import mod2\nfrom mod2 import AClass\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('class AClass(object):\n    pass\n')
         self._transform_module_to_package(mod2)
         mod2 = self.project.get_resource('mod2')
                           get_child('__init__.py').read())
 
     def test_transform_module_to_package_undoing(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod = self.pycore.create_module(pkg, 'mod')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod = testutils.create_module(self.project, 'mod', pkg)
         self._transform_module_to_package(mod)
         self.assertFalse(pkg.has_child('mod.py'))
         self.assertTrue(pkg.get_child('mod').has_child('__init__.py'))
         self.assertFalse(pkg.has_child('mod'))
 
     def test_transform_module_to_package_with_relative_imports(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
         mod1.write('import mod2\nfrom mod2 import AClass\n')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('class AClass(object):\n    pass\n')
         self._transform_module_to_package(mod1)
         new_init = self.project.get_resource('pkg/mod1/__init__.py')
         super(EncapsulateFieldTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
-        self.mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        self.mod = testutils.create_module(self.project, 'mod')
+        self.mod1 = testutils.create_module(self.project, 'mod1')
         self.a_class = 'class A(object):\n    def __init__(self):\n        self.attr = 1\n'
         self.setter_and_getter = '\n    def get_attr(self):\n        return self.attr\n\n' \
                                  '    def set_attr(self, value):\n        self.attr = value\n'
         super(LocalToFieldTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)
         super(IntroduceParameterTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/refactor/change_signature_test.py

         super(ChangeSignatureTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)
         self.assertEquals('def a_func(param, *args):\n    pass\na_func(*[1, 2, 3])\n', self.mod.read())
 
     def test_normalizing_functions_from_other_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func(param):\n    pass\n')
         self.mod.write('import mod1\nmod1.a_func(param=1)\n')
         signature = ChangeSignature(self.project, mod1,

ropetest/refactor/extracttest.py

 import rope.base.exceptions
 import ropetest.testutils as testutils
 from rope.refactor import extract
+from ropetest import testutils
 
 
 class ExtractMethodTest(unittest.TestCase):
         super(ExtractMethodTest, self).tearDown()
 
     def do_extract_method(self, source_code, start, end, extracted, **kwds):
-        testmod = self.pycore.create_module(self.project.root, 'testmod')
+        testmod = testutils.create_module(self.project, 'testmod')
         testmod.write(source_code)
         extractor = extract.ExtractMethod(
             self.project, testmod, start, end)
         return testmod.read()
 
     def do_extract_variable(self, source_code, start, end, extracted, **kwds):
-        testmod = self.pycore.create_module(self.project.root, 'testmod')
+        testmod = testutils.create_module(self.project, 'testmod')
         testmod.write(source_code)
         extractor = extract.ExtractVariable( self.project, testmod, start, end)
         self.project.do(extractor.get_changes(extracted, **kwds))

ropetest/refactor/importutilstest.py

         self.pycore = self.project.get_pycore()
         self.import_tools = ImportTools(self.pycore)
 
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
-        self.pkg1 = self.pycore.create_package(self.project.root, 'pkg1')
-        self.mod1 = self.pycore.create_module(self.pkg1, 'mod1')
-        self.pkg2 = self.pycore.create_package(self.project.root, 'pkg2')
-        self.mod2 = self.pycore.create_module(self.pkg2, 'mod2')
-        self.mod3 = self.pycore.create_module(self.pkg2, 'mod3')
-        p1 = self.pycore.create_package(self.project.root, 'p1')
-        p2 = self.pycore.create_package(p1, 'p2')
-        p3 = self.pycore.create_package(p2, 'p3')
-        m1 = self.pycore.create_module(p3, 'm1')
-        l = self.pycore.create_module(p3, 'l')
+        self.mod = testutils.create_module(self.project, 'mod')
+        self.pkg1 = testutils.create_package(self.project, 'pkg1')
+        self.mod1 = testutils.create_module(self.project, 'mod1', self.pkg1)
+        self.pkg2 = testutils.create_package(self.project, 'pkg2')
+        self.mod2 = testutils.create_module(self.project, 'mod2', self.pkg2)
+        self.mod3 = testutils.create_module(self.project, 'mod3', self.pkg2)
+        p1 = testutils.create_package(self.project, 'p1')
+        p2 = testutils.create_package(self.project, 'p2', p1)
+        p3 = testutils.create_package(self.project, 'p3', p2)
+        m1 = testutils.create_module(self.project, 'm1', p3)
+        l = testutils.create_module(self.project, 'l', p3)
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/refactor/inlinetest.py

         super(InlineTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
-        self.mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        self.mod = testutils.create_module(self.project, 'mod')
+        self.mod2 = testutils.create_module(self.project, 'mod2')
 
     def tearDown(self):
         testutils.remove_project(self.project)
 
     def test_replacing_calls_with_function_definition_in_other_modules(self):
         self.mod.write('def a_func():\n    print(1)\n')
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('import mod\nmod.a_func()\n')
         self._inline2(self.mod, self.mod.read().index('a_func') + 1)
         self.assertEquals('import mod\nprint(1)\n', mod1.read())
 
     def test_replacing_calls_with_function_definition_in_other_modules2(self):
         self.mod.write('def a_func():\n    print(1)\n')
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('import mod\nif True:\n    mod.a_func()\n')
         self._inline2(self.mod, self.mod.read().index('a_func') + 1)
         self.assertEquals('import mod\nif True:\n    print(1)\n', mod1.read())
     def test_replacing_calls_with_method_definition_in_other_modules(self):
         self.mod.write('class A(object):\n    var = 10\n'
                        '    def a_func(self):\n        print(1)\n')
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('import mod\nmod.A().a_func()\n')
         self._inline2(self.mod, self.mod.read().index('a_func') + 1)
         self.assertEquals('import mod\nprint(1)\n', mod1.read())
                           self.mod2.read())
 
     def test_handling_relative_imports_when_inlining(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod3 = self.pycore.create_module(pkg, 'mod3')
-        mod4 = self.pycore.create_module(pkg, 'mod4')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod3 = testutils.create_module(self.project, 'mod3', pkg)
+        mod4 = testutils.create_module(self.project, 'mod4', pkg)
         mod4.write('var = 1\n')
         mod3.write('from . import mod4\n\ndef f():\n    print(mod4.var)\n')
         self.mod.write('import pkg.mod3\n\npkg.mod3.f()\n')
                           self.mod2.read())
 
     def test_relative_imports_and_changing_inlining_body(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod3 = self.pycore.create_module(pkg, 'mod3')
-        mod4 = self.pycore.create_module(pkg, 'mod4')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod3 = testutils.create_module(self.project, 'mod3', pkg)
+        mod4 = testutils.create_module(self.project, 'mod4', pkg)
         mod4.write('var = 1\n')
         mod3.write('import mod4\n\ndef f():\n    print(mod4.var)\n')
         self.mod.write('import pkg.mod3\n\npkg.mod3.f()\n')

ropetest/refactor/movetest.py

         super(MoveRefactoringTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        self.mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        self.mod3 = self.pycore.create_module(self.project.root, 'mod3')
-        self.pkg = self.pycore.create_package(self.project.root, 'pkg')
-        self.mod4 = self.pycore.create_module(self.pkg, 'mod4')
-        self.mod5 = self.pycore.create_module(self.pkg, 'mod5')
+        self.mod1 = testutils.create_module(self.project, 'mod1')
+        self.mod2 = testutils.create_module(self.project, 'mod2')
+        self.mod3 = testutils.create_module(self.project, 'mod3')
+        self.pkg = testutils.create_package(self.project, 'pkg')
+        self.mod4 = testutils.create_module(self.project, 'mod4', self.pkg)
+        self.mod5 = testutils.create_module(self.project, 'mod5', self.pkg)
 
     def tearDown(self):
         testutils.remove_project(self.project)
         self.assertEquals('import pkg.mod5\nprint(pkg.mod5)\n', moved.read())
 
     def test_moving_packages(self):
-        pkg2 = self.pycore.create_package(self.project.root, 'pkg2')
+        pkg2 = testutils.create_package(self.project, 'pkg2')
         self.mod1.write('import pkg.mod4\nprint(pkg.mod4)')
         self._move(self.mod1, self.mod1.read().index('pkg') + 1, pkg2)
         self.assertFalse(self.pkg.exists())
 
     def test_moving_resources_using_move_module_refactoring_for_packages(self):
         self.mod1.write('import pkg\nmy_pkg = pkg')
-        pkg2 = self.pycore.create_package(self.project.root, 'pkg2')
+        pkg2 = testutils.create_package(self.project, 'pkg2')
         mover = move.create_move(self.project, self.pkg)
         mover.get_changes(pkg2).do()
         self.assertEquals('import pkg2.pkg\nmy_pkg = pkg2.pkg', self.mod1.read())
 
     def test_moving_resources_using_move_module_refactoring_for_init_dot_py(self):
         self.mod1.write('import pkg\nmy_pkg = pkg')
-        pkg2 = self.pycore.create_package(self.project.root, 'pkg2')
+        pkg2 = testutils.create_package(self.project, 'pkg2')
         mover = move.create_move(self.project, self.pkg.get_child('__init__.py'))
         mover.get_changes(pkg2).do()
         self.assertEquals('import pkg2.pkg\nmy_pkg = pkg2.pkg', self.mod1.read())

ropetest/refactor/renametest.py

         super(RenameRefactoringTest, self).tearDown()
 
     def _local_rename(self, source_code, offset, new_name):
-        testmod = self.pycore.create_module(self.project.root, 'testmod')
+        testmod = testutils.create_module(self.project, 'testmod')
         testmod.write(source_code)
         changes = Rename(self.project, testmod, offset).\
                   get_changes(new_name, in_file=True)
         self.assertEquals(expected, refactored)
 
     def test_renaming_functions_parameters_and_occurances_in_other_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('def a_func(a_param):\n    print(a_param)\n')
         mod2.write('from mod1 import a_func\na_func(a_param=10)\n')
         self._rename(mod1, mod1.read().index('a_param') + 1, 'new_param')
                           refactored)
 
     def test_renaming_functions_across_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\na_func()\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('import mod1\nmod1.a_func()\n')
         self._rename(mod1, len(mod1.read()) - 5, 'new_func')
         self.assertEquals('def new_func():\n    pass\nnew_func()\n',
         self.assertEquals('import mod1\nmod1.new_func()\n', mod2.read())
 
     def test_renaming_functions_across_modules_from_import(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\na_func()\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('from mod1 import a_func\na_func()\n')
         self._rename(mod1, len(mod1.read()) - 5, 'new_func')
         self.assertEquals('def new_func():\n    pass\nnew_func()\n',
                           mod2.read())
 
     def test_renaming_functions_from_another_module(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\na_func()\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('import mod1\nmod1.a_func()\n')
         self._rename(mod2, len(mod2.read()) - 5, 'new_func')
         self.assertEquals('def new_func():\n    pass\nnew_func()\n',
         self.assertEquals('import mod1\nmod1.new_func()\n', mod2.read())
 
     def test_applying_all_changes_together(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('import mod2\nmod2.a_func()\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('def a_func():\n    pass\na_func()\n')
         self._rename(mod2, len(mod2.read()) - 5, 'new_func')
         self.assertEquals('import mod2\nmod2.new_func()\n', mod1.read())
                           mod2.read())
 
     def test_renaming_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('from mod1 import a_func\n')
         self._rename(mod2, mod2.read().index('mod1') + 1, 'newmod')
         self.assertTrue(not mod1.exists() and
         self.assertEquals('from newmod import a_func\n', mod2.read())
 
     def test_renaming_packages(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
-        mod1 = self.pycore.create_module(pkg, 'mod1')
+        pkg = testutils.create_package(self.project, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1', pkg)
         mod1.write('def a_func():\n    pass\n')
-        mod2 = self.pycore.create_module(pkg, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod2.write('from pkg.mod1 import a_func\n')
         self._rename(mod2, 6, 'newpkg')
         self.assertTrue(self.pycore.find_module('newpkg.mod1') is not None)
         self.assertEquals('from newpkg.mod1 import a_func\n', new_mod2.read())
 
     def test_module_dependencies(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('class AClass(object):\n    pass\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('import mod1\na_var = mod1.AClass()\n')
         self.pycore.resource_to_pyobject(mod2).get_attributes()['mod1']
         mod1.write('def AClass():\n    return 0\n')
         self.assertEquals('import mod1\na_var = mod1.a_func()\n', mod2.read())
 
     def test_renaming_class_attributes(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('class AClass(object):\n    def __init__(self):\n'
                    '        self.an_attr = 10\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('import mod1\na_var = mod1.AClass()\n'
                    'another_var = a_var.an_attr')
 
             mod2.read())
 
     def test_renaming_class_attributes2(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('class AClass(object):\n    def __init__(self):\n'
                    '        an_attr = 10\n        self.an_attr = 10\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('import mod1\na_var = mod1.AClass()\n'
                    'another_var = a_var.an_attr')
 
             mod2.read())
 
     def test_renaming_methods_in_subclasses(self):
-        mod = self.pycore.create_module(self.project.root, 'mod1')
+        mod = testutils.create_module(self.project, 'mod1')
         mod.write('class A(object):\n    def a_method(self):\n        pass\n'
                   'class B(A):\n    def a_method(self):\n        pass\n')
 
             'class B(A):\n    def new_method(self):\n        pass\n', mod.read())
 
     def test_renaming_methods_in_sibling_classes(self):
-        mod = self.pycore.create_module(self.project.root, 'mod1')
+        mod = testutils.create_module(self.project, 'mod1')
         mod.write('class A(object):\n    def a_method(self):\n        pass\n'
                   'class B(A):\n    def a_method(self):\n        pass\n'
                   'class C(A):\n    def a_method(self):\n        pass\n')
             'class C(A):\n    def new_method(self):\n        pass\n', mod.read())
 
     def test_not_renaming_methods_in_hierarchies(self):
-        mod = self.pycore.create_module(self.project.root, 'mod1')
+        mod = testutils.create_module(self.project, 'mod1')
         mod.write('class A(object):\n    def a_method(self):\n        pass\n'
                   'class B(A):\n    def a_method(self):\n        pass\n')
 
             'class B(A):\n    def new_method(self):\n        pass\n', mod.read())
 
     def test_undoing_refactorings(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\na_func()\n')
         self._rename(mod1, len(mod1.read()) - 5, 'new_func')
         self.project.history.undo()
         self.assertEquals('def a_func():\n    pass\na_func()\n', mod1.read())
 
     def test_undoing_renaming_modules(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('def a_func():\n    pass\n')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('from mod1 import a_func\n')
         self._rename(mod2, 6, 'newmod')
         self.project.history.undo()
         self.assertEquals('from mod1 import a_func\n', mod2.read())
 
     def test_rename_in_module_renaming_one_letter_names_for_expressions(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('a = 10\nprint(1+a)\n')
         pymod = self.pycore.get_module('mod1')
         old_pyname = pymod.get_attribute('a')
                           'dict(param=hey)\n', refactored)
 
     def test_renaming_variables_in_init_dot_pys(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        pkg = testutils.create_package(self.project, 'pkg')
         init_dot_py = pkg.get_child('__init__.py')
         init_dot_py.write('a_var = 10\n')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('import pkg\nprint(pkg.a_var)\n')
         self._rename(mod, mod.read().index('a_var') + 1, 'new_var')
         self.assertEquals('new_var = 10\n', init_dot_py.read())
         self.assertEquals('import pkg\nprint(pkg.new_var)\n', mod.read())
 
     def test_renaming_variables_in_init_dot_pys2(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        pkg = testutils.create_package(self.project, 'pkg')
         init_dot_py = pkg.get_child('__init__.py')
         init_dot_py.write('a_var = 10\n')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('import pkg\nprint(pkg.a_var)\n')
         self._rename(init_dot_py,
                      init_dot_py.read().index('a_var') + 1, 'new_var')
         self.assertEquals('import pkg\nprint(pkg.new_var)\n', mod.read())
 
     def test_renaming_variables_in_init_dot_pys3(self):
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        pkg = testutils.create_package(self.project, 'pkg')
         init_dot_py = pkg.get_child('__init__.py')
         init_dot_py.write('a_var = 10\n')
-        mod = self.pycore.create_module(self.project.root, 'mod')
+        mod = testutils.create_module(self.project, 'mod')
         mod.write('import pkg\nprint(pkg.a_var)\n')
         self._rename(mod, mod.read().index('a_var') + 1, 'new_var')
         self.assertEquals('new_var = 10\n', init_dot_py.read())
         self.assertEquals('import pkg\nprint(pkg.new_var)\n', mod.read())
 
     def test_renaming_resources_using_rename_module_refactoring(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod1.write('a_var = 1')
         mod2.write('import mod1\nmy_var = mod1.a_var\n')
         renamer = rename.Rename(self.project, mod1)
         self.assertEquals('import newmod\nmy_var = newmod.a_var\n', mod2.read())
 
     def test_renaming_resources_using_rename_module_refactoring_for_packages(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        pkg = testutils.create_package(self.project, 'pkg')
         mod1.write('import pkg\nmy_pkg = pkg')
         renamer = rename.Rename(self.project, pkg)
         renamer.get_changes('newpkg').do()
         self.assertEquals('import newpkg\nmy_pkg = newpkg', mod1.read())
 
     def test_renaming_resources_using_rename_module_refactoring_for_init_dot_py(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        pkg = self.pycore.create_package(self.project.root, 'pkg')
+        mod1 = testutils.create_module(self.project, 'mod1')
+        pkg = testutils.create_package(self.project, 'pkg')
         mod1.write('import pkg\nmy_pkg = pkg')
         renamer = rename.Rename(self.project, pkg.get_child('__init__.py'))
         renamer.get_changes('newpkg').do()
     def test_renaming_when_unsure(self):
         code = 'class C(object):\n    def a_func(self):\n        pass\n' \
                'def f(arg):\n    arg.a_func()\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_func'),
                      'new_func', unsure=self._true)
             return False
         code = 'class C(object):\n    def a_func(self):\n        pass\n' \
                'def f(arg):\n    arg.a_func()\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_func'), 'new_func', unsure=confirm)
         self.assertEquals(
         code = 'class C1(object):\n    def a_func(self):\n        pass\n' \
                'class C2(object):\n    def a_func(self):\n        pass\n' \
                'c1 = C1()\nc1.a_func()\nc2 = C2()\nc2.a_func()\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_func'), 'new_func', unsure=self._true)
         self.assertEquals(
 
     def test_renaming_in_strings_and_comments(self):
         code = 'a_var = 1\n# a_var\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_var'), 'new_var', docs=True)
         self.assertEquals('new_var = 1\n# new_var\n', mod1.read())
 
     def test_not_renaming_in_strings_and_comments_where_not_visible(self):
         code = 'def f():\n    a_var = 1\n# a_var\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_var'), 'new_var', docs=True)
         self.assertEquals('def f():\n    new_var = 1\n# a_var\n', mod1.read())
 
     def test_not_renaming_all_text_occurrences_in_strings_and_comments(self):
         code = 'a_var = 1\n# a_vard _a_var\n'
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write(code)
         self._rename(mod1, code.index('a_var'), 'new_var', docs=True)
         self.assertEquals('new_var = 1\n# a_vard _a_var\n', mod1.read())
 
     def setUp(self):
         self.project = testutils.sample_project()
-        self.mod = self.project.get_pycore().create_module(
-            self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)
         super(ImplicitInterfacesTest, self).setUp()
         self.project = testutils.sample_project(validate_objectdb=True)
         self.pycore = self.project.get_pycore()
-        self.mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        self.mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        self.mod1 = testutils.create_module(self.project, 'mod1')
+        self.mod2 = testutils.create_module(self.project, 'mod2')
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/refactor/restructuretest.py

         super(RestructureTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
+        self.mod = testutils.create_module(self.project, 'mod')
 
     def tearDown(self):
         testutils.remove_project(self.project)

ropetest/refactor/similarfindertest.py

         super(CheckingFinderTest, self).setUp()
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
-        self.mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        self.mod1 = testutils.create_module(self.project, 'mod1')
 
     def tearDown(self):
         testutils.remove_project(self.project)
         self.assertEquals(1, len(result))
 
     def test_checking_equality_of_imported_pynames(self):
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2 = testutils.create_module(self.project, 'mod2')
         mod2.write('class A(object):\n    pass\n')
         self.mod1.write('from mod2 import A\nan_a = A()\n')
         pymod2 = self.pycore.resource_to_pyobject(mod2)