Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 def test_path2modname(self):
     assert_equal('astvisitor',
                  path2modname(P("sth/pythoscope/astvisitor.py")))
     assert_equal('generator',
                  path2modname(P("sth/pythoscope/generator/__init__.py")))
     assert_equal('generator.adder',
                  path2modname(P("sth/pythoscope/generator/adder.py")))
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    def test_skips_inspection_of_up_to_date_modules(self):
        paths = ["module.py", "something_else.py", P("module/in/directory.py")]
        project = ProjectInDirectory(self.tmpdir).with_modules(paths)

        inspect_project(project)

        for path in paths:
            assert_contains_once(
                self._get_log_output(),
                "DEBUG: %s hasn't changed since last inspection, skipping." %
                path)
Exemplo n.º 6
0
    def test_reports_each_inspected_module(self):
        paths = ["module.py", "something_else.py", P("module/in/directory.py")]
        project = ProjectInDirectory(self.tmpdir).with_modules(paths)
        # Force the inspection by faking files creation time.
        project["module"].created = 0
        project["something_else"].created = 0
        project["module.in.directory"].created = 0

        inspect_project(project)

        for path in paths:
            assert_contains_once(self._get_log_output(),
                                 "INFO: Inspecting module %s." % path)
Exemplo n.º 7
0
    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)