Beispiel #1
0
 def test_duplicates(self, mock_open, mock_os_walk):
     mock_os_walk.return_value = (['.',
                                   None,
                                   ['f1.cpp', 'f2.cpp']],)
     file_handle = mock_open.return_value.__enter__.return_value
     file_handle.read.return_value = "int foo(){haha();\n}"
     files = getSourceFiles(["dir"], [], True)
     self.assertEqual(['./f1.cpp'], list(files))
Beispiel #2
0
 def test_nonduplicates(self, mock_open, mock_os_walk):
     mock_os_walk.return_value = (['.',
                                   None,
                                   ['f1.cpp', 'f2.cpp']],)
     file_handle = mock_open.return_value.__enter__.return_value
     outs = ["int foo(){{haha({param});\n}}".format(param=i) for i in range(2)]
     file_handle.read.side_effect = lambda: outs.pop()
     files = getSourceFiles(["dir"], [], True)
     self.assertEqual(["./f1.cpp", "./f2.cpp"], list(files))
Beispiel #3
0
 def test_exclude_none_supported_files(self, mock_os_walk):
     mock_os_walk.return_value = (['.', 
                                   None,
                                   ['useful.txt']],)
     files = getSourceFiles(["dir"],['exclude_me'])
     self.assertEqual([], list(files))
Beispiel #4
0
 def test_exclude_folder_recursively(self, mock_os_walk):
     mock_os_walk.return_value = (['ut/something', 
                                   None,
                                   ['useful.cpp']],)
     files = getSourceFiles(["dir"], ["ut/*"])
     self.assertEqual([], list(files))
Beispiel #5
0
 def test_exclude_file_name(self, mock_os_walk):
     mock_os_walk.return_value = (['.', 
                                   None,
                                   ['temp.log', 'useful.cpp']],)
     files = getSourceFiles(["dir"], ["*.log"])
     self.assertEqual(["./useful.cpp"], list(files))
Beispiel #6
0
 def test_exlclude_explicit_file_names_doesnot_support(self, mock_isfile):
     mock_isfile.return_value = True
     files = getSourceFiles(["dir/file.log"], [])
     self.assertEqual([], list(files))
Beispiel #7
0
 def test_explicit_file_names(self, mock_isfile):
     mock_isfile.return_value = True
     files = getSourceFiles(["dir/file.c"], [])
     self.assertEqual(["dir/file.c"], list(files))
Beispiel #8
0
 def test_no_matching(self, mock_os_walk):
     mock_os_walk.return_value = []
     files = getSourceFiles(["dir"], [])
     self.assertEqual(0, len(list(files)))