Пример #1
0
 def runApplicationWithArgv(self, argv, print_result, os_walk, mock_open):
     def store_result(result, options):
         self.fileInfos = list(result) 
     os_walk.return_value = [('.', [], ['a.cpp'])]
     mock_open.return_value.__enter__.return_value.read.return_value = self.source_code
     print_result.side_effect = store_result
     lizard_main(argv)
Пример #2
0
 def run_with_mocks(self, argv, src, print_result, mock_open):
     def store_result(result, options):
         self.fileInfos = list(result)
     mock_open.return_value.read.return_value = src
     print_result.side_effect = store_result
     lizard_main(argv)
     return self.fileInfos
Пример #3
0
    def runApplicationWithArgv(self, argv, print_result, os_walk, mock_open):
        def store_result(result, options):
            self.fileInfos = list(result)

        os_walk.return_value = [('.', [], ['a.cpp'])]
        mock_open.return_value.__enter__.return_value.read.return_value = self.source_code
        print_result.side_effect = store_result
        lizard_main(argv)
Пример #4
0
    def testEmptyResult(self, print_result, os_walk, mock_open, _):
        def check_empty_result(result, options, scheme):
            self.assertEqual([], list(result))
            return 0

        os_walk.return_value = [('.', [], [])]
        print_result.side_effect = check_empty_result
        lizard_main(['lizard'])
Пример #5
0
 def run_with_mocks(self, argv, src, print_result, mock_open):
     def store_result(result, options, scheme):
         self.fileInfos = list(result)
         return self.returned_warning_count
     mock_open.return_value = src
     print_result.side_effect = store_result
     lizard_main(argv)
     return self.fileInfos
Пример #6
0
    def testEmptyResult(self, print_result, os_walk, mock_open, _):

        def check_empty_result(result, options):
            self.assertEqual([], list(result))

        os_walk.return_value = [('.', [], [])]
        print_result.side_effect = check_empty_result
        lizard_main(['lizard'])
Пример #7
0
 def testMutipleFilesInArgv(self, print_result, os_walk, mock_open):
     def check_result(result, options):
         fileInfos = list(result) 
         self.assertEqual(1, len(fileInfos))
         self.assertEqual('foo', fileInfos[0].function_list[0].name)
     os_walk.return_value = [('.', [], ['a.cpp'])]
     mock_open.return_value.__enter__.return_value.read.return_value = "void foo(){}"
     print_result.side_effect = check_result
     lizard_main(['lizard'])
Пример #8
0
    def run_with_mocks(self, argv, src, print_result, mock_open):
        def store_result(result, options, scheme):
            self.fileInfos = list(result)
            return self.returned_warning_count

        mock_open.return_value = src
        print_result.side_effect = store_result
        lizard_main(argv)
        return self.fileInfos
Пример #9
0
 def testFilesWithFunction(self, print_result, os_walk, mock_open, _):
     def check_result(result, options, scheme):
         fileInfos = list(result)
         self.assertEqual(1, len(fileInfos))
         self.assertEqual('foo', fileInfos[0].function_list[0].name)
         return 0
     os_walk.return_value = [('.', [], ['a.cpp'])]
     mock_open.return_value.read.return_value = "void foo(){}"
     print_result.side_effect = check_result
     lizard_main(['lizard'])
Пример #10
0
    def testMutipleFilesInArgv(self, print_result, os_walk, mock_open):
        def check_result(result, options):
            fileInfos = list(result)
            self.assertEqual(1, len(fileInfos))
            self.assertEqual('foo', fileInfos[0].function_list[0].name)

        os_walk.return_value = [('.', [], ['a.cpp'])]
        mock_open.return_value.__enter__.return_value.read.return_value = "void foo(){}"
        print_result.side_effect = check_result
        lizard_main(['lizard'])
Пример #11
0
    def testFilesWithFunction(self, print_result, os_walk, mock_open, _):
        def check_result(result, options, scheme):
            fileInfos = list(result)
            self.assertEqual(1, len(fileInfos))
            self.assertEqual('foo', fileInfos[0].function_list[0].name)
            return 0

        os_walk.return_value = [('.', [], ['a.cpp'])]
        mock_open.return_value = "void foo(){}"
        print_result.side_effect = check_result
        lizard_main(['lizard'])
Пример #12
0
 def testGetCurrentFolderByDefault(self, print_result, os_walk, mock_open):
     print_result.side_effect = self.exhaust_result
     lizard_main(['lizard'])
     os_walk.assert_called_once_with('.', topdown=False)
Пример #13
0
from lizard import lizard_main
import cProfile, pstats, StringIO
import sys

if __name__ == "__main__":
    pr = cProfile.Profile()
    pr.enable()
    lizard_main(sys.argv)
    pr.disable()
    s = StringIO.StringIO()
    sortby = 'tottime'
    ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
    ps.print_stats()
    print s.getvalue()
Пример #14
0
 def testGetCurrentFolderByDefault(self, print_result, os_walk, mock_open):
     print_result.side_effect = self.exhaust_result
     lizard_main(['lizard'])
     os_walk.assert_called_once_with('.', topdown=False)
Пример #15
0
from lizard import lizard_main
import cProfile, pstats, StringIO
import sys


if __name__ == "__main__":
    pr = cProfile.Profile()
    pr.enable()
    lizard_main(sys.argv)
    pr.disable()
    s = StringIO.StringIO()
    sortby = 'tottime'
    ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
    ps.print_stats()
    print s.getvalue()


Пример #16
0
 def testEmptyResult(self, print_result, os_walk, mock_open):
     os_walk.return_value = [('.', [], [])]
     print_result.side_effect = self.check_empty_result
     lizard_main(['lizard'])
Пример #17
0
 def testEmptyResult(self, print_result, os_walk, mock_open):
     os_walk.return_value = [('.', [], [])]
     print_result.side_effect = self.check_empty_result
     lizard_main(['lizard'])