Beispiel #1
0
    def test_NoFilesMultipleThread(self):
        call_count = 0

        def analyzer(filename):
            call_count += 1

        mapFilesToAnalyzer([], analyzer, 2)
        self.assertEqual(0, call_count)
Beispiel #2
0
    def test_NoFiles(self):
        call_count = 0

        def analyzer(filename):
            call_count += 1

        mapFilesToAnalyzer([], analyzer, 1)
        self.assertEqual(0, call_count)
Beispiel #3
0
 def test_fileInfomation(self, mock_open):
     mock_open.return_value.read.return_value = "int foo(){haha();\n}"
     r = mapFilesToAnalyzer(["f1.c"], self.analyzer, 1)
     fileInfo = list(r)[0]
     self.assertEqual(1, fileInfo.nloc)
     self.assertEqual(2, fileInfo.average_NLOC)
     self.assertEqual(1, fileInfo.average_CCN)
     self.assertEqual(9, fileInfo.average_token)
Beispiel #4
0
 def test_fileInfomation(self, mock_open):
     file_handle = mock_open.return_value.__enter__.return_value
     file_handle.read.return_value = "int foo(){haha();\n}"
     r = mapFilesToAnalyzer(["f1.c"], self.analyzer, 1)
     fileInfo = list(r)[0]
     self.assertEqual(1, fileInfo.nloc)
     self.assertEqual(2, fileInfo.average_NLOC)
     self.assertEqual(1, fileInfo.average_CCN)
     self.assertEqual(9, fileInfo.average_token)
Beispiel #5
0
 def test_analyze_c_file(self, mock_open):
     file_handle = mock_open.return_value.__enter__.return_value
     file_handle.read.return_value = "int foo(){haha();\n}"
     r = mapFilesToAnalyzer(["f1.c"], self.analyzer, 1)
     self.assertEqual(1, len([x for x in r]))
Beispiel #6
0
 def test_analyze_c_file_with_multiple_thread(self, mock_open):
     file_handle = mock_open.return_value.read.return_value = "int foo(){haha();\n}"
     r = mapFilesToAnalyzer(["f1.c"], self.analyzer, 2)
     self.assertEqual(1, len([x for x in r]))
Beispiel #7
0
 def test_MoreFilesMultipleThread(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["f1", "f2"], analyzer, 2)
     self.assertEqual(["f1", "f2"], [x for x in r])
Beispiel #8
0
 def test_MoreFiles(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["f1", "f2"], analyzer, 1)
     self.assertEqual(["f1", "f2"], [x for x in r])
Beispiel #9
0
 def test_OneFileMultipleThread(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["filename"], analyzer, 2)
     self.assertEqual(["filename"], [x for x in r])
Beispiel #10
0
 def test_OneFile(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["filename"], analyzer, 1)
     self.assertEqual(["filename"], [x for x in r])
Beispiel #11
0
 def test_NoFilesMultipleThread(self):
     call_count = 0
     def analyzer(filename):
         call_count += 1
     mapFilesToAnalyzer([], analyzer, 2)
     self.assertEqual(0, call_count)
Beispiel #12
0
 def test_NoFiles(self):
     call_count = 0
     def analyzer(filename):
         call_count += 1
     mapFilesToAnalyzer([], analyzer, 1)
     self.assertEqual(0, call_count)
Beispiel #13
0
 def test_OneFile(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["filename"], analyzer, 1)
     self.assertEqual(["filename"], [x for x in r])
Beispiel #14
0
 def test_analyze_c_file_with_multiple_thread(self, mock_open):
     file_handle = mock_open.return_value.__enter__.return_value
     file_handle.read.return_value = "int foo(){haha();\n}"
     r = mapFilesToAnalyzer(["f1.c"], self.analyzer, 2)
     self.assertEqual(1, len([x for x in r]))
Beispiel #15
0
 def test_MoreFilesMultipleThread(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["f1", "f2"], analyzer, 2)
     self.assertEqual(["f1", "f2"], [x for x in r])
Beispiel #16
0
 def test_MoreFiles(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["f1", "f2"], analyzer, 1)
     self.assertEqual(["f1", "f2"], [x for x in r])
Beispiel #17
0
 def test_OneFileMultipleThread(self):
     analyzer = analyzer_mock
     r = mapFilesToAnalyzer(["filename"], analyzer, 2)
     self.assertEqual(["filename"], [x for x in r])