コード例 #1
0
    def test_analyze_functions(self):
        """Test whether the analyze method returns functions information"""

        file_path = os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)
        file_analyzer = FileAnalyzer(details=True)
        analysis = file_analyzer.analyze(file_path)

        self.assertIn('ccn', analysis)
        self.assertIn('avg_loc', analysis)
        self.assertIn('avg_tokens', analysis)
        self.assertIn('loc', analysis)
        self.assertIn('tokens', analysis)
        self.assertIn('blanks', analysis)
        self.assertIn('comments', analysis)
        self.assertIn('funs', analysis)

        for fd in analysis['funs']:
            self.assertIn('ccn', fd)
            self.assertIn('tokens', fd)
            self.assertIn('loc', fd)
            self.assertIn('lines', fd)
            self.assertIn('name', fd)
            self.assertIn('args', fd)
            self.assertIn('start', fd)
            self.assertIn('end', fd)
コード例 #2
0
    def test_analyze_no_functions(self):
        """Test whether the analyze method works"""

        file_path = os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)
        file_analyzer = FileAnalyzer()
        analysis = file_analyzer.analyze(file_path)

        self.assertNotIn('funs', analysis)
        self.assertIn('ccn', analysis)
        self.assertIn('avg_loc', analysis)
        self.assertIn('avg_tokens', analysis)
        self.assertIn('loc', analysis)
        self.assertIn('tokens', analysis)
        self.assertIn('blanks', analysis)
        self.assertIn('comments', analysis)
コード例 #3
0
    def test_init(self):
        """Test initialization"""

        file_analyzer = FileAnalyzer()

        self.assertIsInstance(file_analyzer, FileAnalyzer)
        self.assertIsInstance(file_analyzer.cloc, Cloc)
        self.assertIsInstance(file_analyzer.lizard, Lizard)
        self.assertFalse(file_analyzer.details)

        file_analyzer = FileAnalyzer(details=True)

        self.assertIsInstance(file_analyzer, FileAnalyzer)
        self.assertIsInstance(file_analyzer.cloc, Cloc)
        self.assertIsInstance(file_analyzer.lizard, Lizard)
        self.assertTrue(file_analyzer.details)