def test_replaces_old_module_objects_with_new_ones_during_create_module(self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) new_module = project.create_module(P("other/module.py")) assert_length(project.get_modules(), 3) assert project[P("other/module.py")] is new_module
def test_replaces_old_module_objects_with_new_ones_during_create_module( self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) new_module = project.create_module(P("other/module.py")) assert_length(project.get_modules(), 3) assert project[P("other/module.py")] is new_module
def test_replaces_module_instance_in_test_cases_associated_modules_during_module_replacement(self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) test_class = create(TestClass, name='TestAnything', associated_modules=[project[P("other/module.py")]]) add_test_case(project[P("other/module.py")], test_class) new_module = project.create_module(P("other/module.py")) assert_length(test_class.associated_modules, 1) assert test_class.associated_modules[0] is new_module
def test_replaces_module_instance_in_test_cases_associated_modules_during_module_replacement( self): paths = ["module.py", P("sub/dir/module.py"), P("other/module.py")] project = ProjectWithModules(paths) test_class = create(TestClass, name='TestAnything', associated_modules=[project[P("other/module.py")]]) add_test_case(project[P("other/module.py")], test_class) new_module = project.create_module(P("other/module.py")) assert_length(test_class.associated_modules, 1) assert test_class.associated_modules[0] is new_module
def test_can_be_queried_for_modules_by_their_locator(self): paths = ["module.py", P("sub/dir/module.py"), P("package/__init__.py")] locators = ["module", "sub.dir.module", "package"] project = ProjectWithModules(paths) for path, locator in zip(paths, locators): assert_equal(path, project[locator].subpath)
def test_can_be_queried_for_modules_by_their_path(self): paths = ["module.py", P("sub/dir/module.py"), P("package/__init__.py")] project = ProjectWithModules(paths) for path in paths: assert_equal(path, project[path].subpath)
def ProjectAndTestClass(test_module_name): project = ProjectWithModules(["module.py", test_module_name]) test_class = TestClass("TestSomething", associated_modules=[project["module"]]) return project, test_class