コード例 #1
0
class TestIndexDocstrings(object):
    def setUp(self):
        self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package2.tar.gz"))

        modules = 5
        classes = 2
        functions = 4
        methods = 3

        self.documentable_objects = modules + classes + functions + methods
        self.docstring_count = 7

        self.index_float = float(self.docstring_count) / self.documentable_objects
        self.index_int = int(ceil(self.index_float*100))

    def tearDown(self):
        self.cheesecake.cleanup()

    def test_index_docstrings(self):
        index = self.cheesecake.index["DOCUMENTATION"]["IndexDocstrings"]
        index.compute_with(self.cheesecake)

        assert index.name == "IndexDocstrings"
        assert index.value == self.index_int
        assert index.details == "found %d/%d=%.2f%% objects with docstrings" %\
                            (self.docstring_count, self.documentable_objects, self.index_float*100)
コード例 #2
0
class TestInitCleanup(object):
    def tearDown(self):
        if hasattr(self, 'cheesecake'):
            if os.path.isdir(self.cheesecake.sandbox):
                rmtree(self.cheesecake.sandbox)
        if hasattr(self, 'logfile'):
            if os.path.isfile(self.logfile):
                os.unlink(self.logfile)

    def test_init(self):
        self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"))
        assert os.path.isdir(self.cheesecake.sandbox_pkg_dir)
        assert os.path.isfile(self.cheesecake.sandbox_pkg_file)
        self.logfile = self.cheesecake.logfile
        assert os.path.isfile(self.logfile)

    def test_init_custom_logfile(self):
        self.logfile = tempfile.mktemp()
        self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"),
                                     logfile=self.logfile)
        assert os.path.isdir(self.cheesecake.sandbox_pkg_dir)
        assert os.path.isfile(self.cheesecake.sandbox_pkg_file)
        assert os.path.isfile(self.logfile)

    def test_cleanup_after_install(self):
        self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"))
        self.cheesecake.cleanup()
        assert not os.path.exists(self.cheesecake.sandbox_pkg_dir)
        assert not os.path.exists(self.cheesecake.sandbox_pkg_file)
        assert not os.path.exists(self.cheesecake.sandbox_install_dir)
        assert not os.path.exists(self.cheesecake.sandbox)
        self.logfile = self.cheesecake.logfile
        assert not os.path.isfile(self.logfile)
コード例 #3
0
ファイル: project_stats.py プロジェクト: xi/project-stats
def cheesecake_index(name):
    if Cheesecake is not None:
        # does not seem to be meant to be used as a library
        c = Cheesecake(name=name, quiet=True, lite=True)
        value = c.index.compute_with(c)
        max_value = c.index.max_value
        c.cleanup()
        return value * 100 / max_value
    else:
        return None
コード例 #4
0
 def test_init_custom_logfile(self):
     self.logfile = tempfile.mktemp()
     self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"),
                                  logfile=self.logfile)
     assert os.path.isdir(self.cheesecake.sandbox_pkg_dir)
     assert os.path.isfile(self.cheesecake.sandbox_pkg_file)
     assert os.path.isfile(self.logfile)
コード例 #5
0
 def test_cleanup_after_install(self):
     self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"))
     self.cheesecake.cleanup()
     assert not os.path.exists(self.cheesecake.sandbox_pkg_dir)
     assert not os.path.exists(self.cheesecake.sandbox_pkg_file)
     assert not os.path.exists(self.cheesecake.sandbox_install_dir)
     assert not os.path.exists(self.cheesecake.sandbox)
     self.logfile = self.cheesecake.logfile
     assert not os.path.isfile(self.logfile)
コード例 #6
0
    def setUp(self):
        self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package2.tar.gz"))

        modules = 5
        classes = 2
        functions = 4
        methods = 3

        self.documentable_objects = modules + classes + functions + methods
        self.docstring_count = 7

        self.index_float = float(self.docstring_count) / self.documentable_objects
        self.index_int = int(ceil(self.index_float*100))
コード例 #7
0
 def test_init(self):
     self.cheesecake = Cheesecake(path=os.path.join(DATA_PATH, "package1.tar.gz"))
     assert os.path.isdir(self.cheesecake.sandbox_pkg_dir)
     assert os.path.isfile(self.cheesecake.sandbox_pkg_file)
     self.logfile = self.cheesecake.logfile
     assert os.path.isfile(self.logfile)