Ejemplo n.º 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)
Ejemplo n.º 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)