Пример #1
0
 def test_filter_file_nonarchive_archivesonly(self):
     settings = self.get_settings()
     settings.archivesonly = True
     settings.searcharchives = True
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertFalse(searcher.filter_file(f))
Пример #2
0
 def test_filter_file_nonarchive_archivesonly(self):
     settings = self.get_settings()
     settings.archivesonly = True
     settings.searcharchives = True
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertFalse(searcher.filter_file(f))
Пример #3
0
 def test_filter_file_is_hidden_file(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='',
                    filename='.gitignore',
                    filetype=FileType.Unknown)
     self.assertFalse(searcher.filter_file(f))
Пример #4
0
 def test_filter_file_archive_no_searcharchives(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='',
                    filename='archive.zip',
                    filetype=FileType.Archive)
     self.assertFalse(searcher.filter_file(f))
Пример #5
0
 def test_filter_file_archive_archivesonly(self):
     settings = self.get_settings()
     settings.archivesonly = True
     settings.searcharchives = True
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='archive.zip', filetype=FileType.Archive)
     self.assertTrue(searcher.filter_file(f))
Пример #6
0
 def test_filter_file_hidden_includehidden(self):
     settings = self.get_settings()
     settings.excludehidden = False
     searcher = Searcher(settings)
     f = SearchFile(path='',
                    filename='.gitignore',
                    filetype=FileType.Unknown)
     self.assertTrue(searcher.filter_file(f))
Пример #7
0
 def test_filter_file_archive_archivesonly(self):
     settings = self.get_settings()
     settings.archivesonly = True
     settings.searcharchives = True
     searcher = Searcher(settings)
     f = SearchFile(path='',
                    filename='archive.zip',
                    filetype=FileType.Archive)
     self.assertTrue(searcher.filter_file(f))
Пример #8
0
    def test_search_multiline_string(self):
        settings = self.get_settings()
        searcher = Searcher(settings)
        testfile = self.get_test_file()
        results = []
        try:
            fo = open(testfile, 'r')
            results = searcher.search_line_iterator(fo)
            fo.close()
        except IOError as e:
            print('IOError: {0!s}: {1!s}'.format(e, sf))
        self.assertEqual(len(results), 2)

        firstResult = results[0]
        self.assertEqual(firstResult.linenum, 23)
        self.assertEqual(firstResult.match_start_index, 3)
        self.assertEqual(firstResult.match_end_index, 11)

        secondResult = results[1]
        self.assertEqual(secondResult.linenum, 29)
        self.assertEqual(secondResult.match_start_index, 24)
        self.assertEqual(secondResult.match_end_index, 32)
Пример #9
0
    def test_search_multiline_string(self):
        settings = self.get_settings()
        searcher = Searcher(settings)
        testfile = self.get_test_file()
        results = []
        try:
            fo = open(testfile, 'r')
            results = searcher.search_line_iterator(fo)
            fo.close()
        except IOError as e:
            print('IOError: {0!s}'.format(e))
        self.assertEqual(len(results), 2)

        firstResult = results[0]
        self.assertEqual(firstResult.linenum, 23)
        self.assertEqual(firstResult.match_start_index, 3)
        self.assertEqual(firstResult.match_end_index, 11)

        secondResult = results[1]
        self.assertEqual(secondResult.linenum, 29)
        self.assertEqual(secondResult.match_start_index, 24)
        self.assertEqual(secondResult.match_end_index, 32)
Пример #10
0
 def test_is_search_file_matches_out_pattern(self):
     settings = self.get_settings()
     settings.add_pattern('Search', 'out_filepatterns')
     searcher = Searcher(settings)
     f = 'Searcher.pm'
     self.assertFalse(searcher.is_search_file(f))
Пример #11
0
 def test_is_search_file_no_match_out_extension(self):
     settings = self.get_settings()
     settings.add_comma_delimited_exts('py', 'out_extensions')
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #12
0
 def test_filter_file_is_hidden_file(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='.gitignore', filetype=FileType.Unknown)
     self.assertFalse(searcher.filter_file(f))
Пример #13
0
 def test_is_search_file_matches_out_pattern(self):
     settings = self.get_settings()
     settings.add_patterns('Search', 'out_filepatterns')
     searcher = Searcher(settings)
     f = 'Searcher.pm'
     self.assertFalse(searcher.is_search_file(f))
Пример #14
0
 def test_is_archive_search_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #15
0
 def test_filter_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertTrue(searcher.filter_file(f))
Пример #16
0
 def test_is_archive_search_file_no_match_out_extension(self):
     settings = self.get_settings()
     settings.add_comma_delimited_exts('gz', 'out_archiveextensions')
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #17
0
 def test_is_search_dir_no_patterns(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = 'plsearch'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #18
0
 def test_is_archive_search_file_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_patterns('archives', 'out_archivefilepatterns')
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #19
0
 def test_filter_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertTrue(searcher.filter_file(f))
Пример #20
0
 def test_filter_file_archive_no_searcharchives(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='archive.zip', filetype=FileType.Archive)
     self.assertFalse(searcher.filter_file(f))
Пример #21
0
 def test_filter_file_hidden_includehidden(self):
     settings = self.get_settings()
     settings.excludehidden = False
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='.gitignore', filetype=FileType.Unknown)
     self.assertTrue(searcher.filter_file(f))
Пример #22
0
 def test_is_search_file_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_pattern('Search', 'out_filepatterns')
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #23
0
 def test_is_archive_search_file_no_match_out_extension(self):
     settings = self.get_settings()
     settings.add_exts('gz', 'out_archiveextensions')
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #24
0
 def test_is_archive_search_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #25
0
 def test_is_search_dir_no_patterns(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = 'plsearch'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #26
0
 def test_is_archive_search_file_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_pattern('archives', 'out_archivefilepatterns')
     searcher = Searcher(settings)
     f = 'archive.zip'
     self.assertTrue(searcher.is_archive_search_file(f))
Пример #27
0
 def test_is_search_dir_double_dot(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = '..'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #28
0
 def test_filter_file_not_is_search_file(self):
     settings = self.get_settings()
     settings.add_comma_delimited_exts('pl', 'in_extensions')
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertFalse(searcher.filter_file(f))
Пример #29
0
 def test_is_search_dir_hidden_dir_include_hidden(self):
     settings = self.get_settings()
     settings.excludehidden = False
     searcher = Searcher(settings)
     dir = '.git'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #30
0
 def test_is_search_file_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_patterns('Search', 'out_filepatterns')
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #31
0
 def test_is_search_file_no_match_out_extension(self):
     settings = self.get_settings()
     settings.add_exts('py', 'out_extensions')
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #32
0
 def test_is_search_dir_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_patterns('pysearch', 'out_dirpatterns')
     searcher = Searcher(settings)
     dir = 'plsearch'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #33
0
 def test_filter_file_not_is_search_file(self):
     settings = self.get_settings()
     settings.add_exts('pl', 'in_extensions')
     searcher = Searcher(settings)
     f = SearchFile(path='', filename='FileUtil.pm', filetype=FileType.Text)
     self.assertFalse(searcher.filter_file(f))
Пример #34
0
 def test_is_search_dir_double_dot(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = '..'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #35
0
 def test_is_search_dir_hidden_dir(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = '.git'
     self.assertFalse(searcher.is_search_dir(dir))
Пример #36
0
 def test_is_search_dir_no_match_out_pattern(self):
     settings = self.get_settings()
     settings.add_pattern('pysearch', 'out_dirpatterns')
     searcher = Searcher(settings)
     dir = 'plsearch'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #37
0
 def test_is_search_dir_hidden_dir_include_hidden(self):
     settings = self.get_settings()
     settings.excludehidden = False
     searcher = Searcher(settings)
     dir = '.git'
     self.assertTrue(searcher.is_search_dir(dir))
Пример #38
0
 def test_is_search_dir_hidden_dir(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     dir = '.git'
     self.assertFalse(searcher.is_search_dir(dir))
Пример #39
0
 def test_is_search_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #40
0
 def test_is_search_file_matches_by_default(self):
     settings = self.get_settings()
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertTrue(searcher.is_search_file(f))
Пример #41
0
 def test_is_search_file_no_match_in_extension(self):
     settings = self.get_settings()
     settings.add_exts('pl', 'in_extensions')
     searcher = Searcher(settings)
     f = 'FileUtil.pm'
     self.assertFalse(searcher.is_search_file(f))