예제 #1
0
 def test_csv_header(self):
     options_mock = Mock()
     options_mock.verbose = True
     options_mock.extensions = []
     csv_output(AllResult([self.fileSummary]), options_mock)
     self.assertRegexpMatches(sys.stdout.stream,
                              r"NLOC,CCN,token,PARAM,length,location,file,function,long_name,start,end")
예제 #2
0
 def test_csv_no_header(self):
     options_mock = Mock()
     options_mock.verbose = False
     options_mock.extensions = []
     csv_output(AllResult([self.fileSummary]), options_mock)
     self.assertEqual(
         '1,1,1,0,0,"foo@100-100@FILENAME","FILENAME","foo","foo",100,100',
         sys.stdout.stream.splitlines()[0])
예제 #3
0
    def test_print_fileinfo(self):
        self.foo.end_line = 100
        self.foo.cyclomatic_complexity = 16
        fileStat = FileInformation("FILENAME", 1, [self.foo])

        csv_output(AllResult([fileStat]), True)

        self.assertEqual(
            '1,16,1,0,0,"foo@100-100@FILENAME","FILENAME","foo","foo",100,100',
            sys.stdout.stream.splitlines()[1])
예제 #4
0
 def test_csv_header_with_extension(self):
     options_mock = Mock()
     options_mock.verbose = True
     extension_mock = Mock()
     extension_mock.__class__.__name__ = 'LizardExtension'
     extension_mock.FUNCTION_INFO = {"exit_count": {"caption": "exits"}}
     options_mock.extensions = [extension_mock]
     results = AllResult([self.fileSummary])
     results.result[0].function_list[0].exit_count = 1
     csv_output(results, options_mock)
     self.assertRegexpMatches(sys.stdout.stream,
                              r"NLOC,CCN,token,PARAM,length,location,file,function,long_name,start,end,exits")
예제 #5
0
    def test_print_extension(self):
        options_mock = Mock()
        options_mock.verbose = True
        options_mock.extensions = []

        self.foo.end_line = 100
        self.foo.cyclomatic_complexity = 16
        fileStat = FileInformation("FILENAME", 1, [self.foo])

        csv_output(AllResult([fileStat]), options_mock)

        self.assertEqual(
            '1,16,1,0,0,"foo@100-100@FILENAME","FILENAME","foo","foo",100,100',
            sys.stdout.stream.splitlines()[1])
예제 #6
0
    def test_csv_no_header_with_extension(self):
        options_mock = Mock()
        options_mock.verbose = False
        options_mock.extensions = []
        extension_mock = Mock()
        extension_mock.__class__.__name__ = 'LizardExtension'
        extension_mock.FUNCTION_INFO = {"exit_count": {"caption": "exits"}}
        options_mock.extensions = [extension_mock]

        results = AllResult([self.fileSummary])
        results.result[0].function_list[0].exit_count = 1
        csv_output(results, options_mock)

        self.assertEqual(
            '1,1,1,0,0,"foo@100-100@FILENAME","FILENAME","foo","foo",100,100,1',
            sys.stdout.stream.splitlines()[0])
예제 #7
0
class TestXMLOutput(unittest.TestCase):
    foo = FunctionInfo("foo", '', 100)
    foo.cyclomatic_complexity = 16
    file_infos = [FileInformation('f1.c', 1, [foo])]
    xml = xml_output(AllResult(file_infos), True)

    def test_xml_output(self):
        self.assertIn('''foo at f1.c:100''', self.xml)

    def test_xml_stylesheet(self):
        self.assertIn('''<?xml-stylesheet type="text/xsl" href="https://raw.githubusercontent.com/terryyin/lizard/master/lizard.xsl"?>''', self.xml)

    def test_xml_output_on_empty_folder(self):
        xml_empty = xml_output(AllResult([]), True)
        self.assertIn('''<sum label="NCSS" value="0"/>''', xml_empty)
        self.assertIn('''<sum label="CCN" value="0"/>''', xml_empty)
        self.assertIn('''<sum label="Functions" value="0"/>''', xml_empty)
예제 #8
0
 def test_xml_output_on_empty_folder(self):
     xml_empty = xml_output(AllResult([]), True)
     self.assertIn('''<sum label="NCSS" value="0"/>''', xml_empty)
     self.assertIn('''<sum label="CCN" value="0"/>''', xml_empty)
     self.assertIn('''<sum label="Functions" value="0"/>''', xml_empty)
예제 #9
0
 def test_csv_no_header(self):
     csv_output(AllResult([self.fileSummary]), False)
     self.assertEqual(
         '1,1,1,0,0,"foo@100-100@FILENAME","FILENAME","foo","foo",100,100',
         sys.stdout.stream.splitlines()[0])
예제 #10
0
 def test_csv_header(self):
     csv_output(AllResult([self.fileSummary]), True)
     self.assertRegexpMatches(
         sys.stdout.stream,
         r"NLOC,CCN,token,PARAM,length,location,file,function,long_name,start,end"
     )