예제 #1
0
    def _test_encoding(self, fn):
        """Test encoding"""

        fullpath = self.write_file(fn)

        # Add Unicode paths to encourage a crash.
        subdir = os.path.join(self.tempdir, u'ɡælɪk.dir')
        os.mkdir(subdir)
        subfile = os.path.join(subdir, u'ɡælɪk.file')
        common.touch_file(subfile)

        ds = DeepScan()
        for use_unicode in (False, True):
            if use_unicode:
                search_dir = unicode(self.tempdir)
            else:
                search_dir = self.tempdir
                self.assertIsInstance(search_dir, str)
            ds.add_search(search_dir, '\.[Bb][Aa][Kk]$')
            found = False
            for ret in ds.scan():
                if ret == True:
                    # True is used to yield to GTK+, but it is not
                    # needed in this test.
                    continue
                self.assertExists(ret)
                if ret == fullpath:
                    found = True
            self.assertTrue(found, u"Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assertNotExists(fullpath)

        import shutil
        shutil.rmtree(subdir)
예제 #2
0
    def _test_encoding(self, fn):
        """Test encoding"""

        fullpath = self.write_file(fn)

        # Add Unicode paths to encourage a crash.
        subdir = os.path.join(self.tempdir, u'ɡælɪk.dir')
        os.mkdir(subdir)
        subfile = os.path.join(subdir, u'ɡælɪk.file')
        common.touch_file(subfile)

        ds = DeepScan()
        for use_unicode in (False, True):
            if use_unicode:
                search_dir = unicode(self.tempdir)
            else:
                search_dir = self.tempdir
                self.assertIsInstance(search_dir, str)
            ds.add_search(search_dir, '\.[Bb][Aa][Kk]$')
            found = False
            for ret in ds.scan():
                if ret == True:
                    # True is used to yield to GTK+, but it is not
                    # needed in this test.
                    continue
                self.assertExists(ret)
                if ret == fullpath:
                    found = True
            self.assertTrue(found, u"Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assertNotExists(fullpath)

        import shutil
        shutil.rmtree(subdir)
예제 #3
0
    def _test_encoding(self, fn):
        """Test encoding"""

        fullpath = self.write_file(fn)

        # Add Unicode paths to encourage a crash.
        subdir = os.path.join(self.tempdir, 'ɡælɪk.dir')
        os.mkdir(subdir)
        subfile = os.path.join(subdir, 'ɡælɪk.file')
        common.touch_file(subfile)

        searches = {self.tempdir: []}
        searches[self.tempdir].append(
            Search(command='delete', regex='\.[Bb][Aa][Kk]$'))
        ds = DeepScan(searches)
        found = False
        for cmd in ds.scan():
            if cmd == True:
                # True is used to yield to GTK+, but it is not
                # needed in this test.
                continue
            self.assertExists(cmd.path)
            if cmd.path == fullpath:
                found = True
        self.assertTrue(found, "Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assertNotExists(fullpath)

        import shutil
        shutil.rmtree(subdir)
예제 #4
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     path = os.path.expanduser('~')
     searches = {path: []}
     for regex in ('^Makefile$', '~$', 'bak$', '^Thumbs.db$',
                   '^Thumbs.db:encryptable$'):
         searches[path].append(Search(command='delete', regex=regex))
     ds = DeepScan(searches)
     for cmd in ds.scan():
         if True == cmd:
             # it's yielding control to the GTK idle loop
             continue
         self.assertLExists(cmd.path)
예제 #5
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     ds = DeepScan()
     path = expanduser('~')
     ds.add_search(path, '^Makefile$')
     ds.add_search(path, '~$')
     ds.add_search(path, 'bak$')
     ds.add_search(path, '^Thumbs.db$')
     ds.add_search(path, '^Thumbs.db:encryptable$')
     for ret in ds.scan():
         if True == ret:
             # it's yielding control to the GTK idle loop
             continue
         self.assertLExists(ret)
예제 #6
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     ds = DeepScan()
     path = expanduser('~')
     ds.add_search(path, '^Makefile$')
     ds.add_search(path, '~$')
     ds.add_search(path, 'bak$')
     ds.add_search(path, '^Thumbs.db$')
     ds.add_search(path, '^Thumbs.db:encryptable$')
     for ret in ds.scan():
         if True == ret:
             # it's yielding control to the GTK idle loop
             continue
         self.assertLExists(ret)
예제 #7
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     ds = DeepScan()
     path = os.path.expanduser("~")
     ds.add_search(path, "^Makefile$")
     ds.add_search(path, "~$")
     ds.add_search(path, "bak$")
     ds.add_search(path, "^Thumbs.db$")
     ds.add_search(path, "^Thumbs.db:encryptable$")
     for ret in ds.scan():
         if True == ret:
             # it's yielding control to the GTK idle loop
             continue
         self.assert_(isinstance(ret, (str, unicode)), "Expecting string but got '%s' (%s)" % (ret, str(type(ret))))
         self.assert_(os.path.lexists(ret))
예제 #8
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     ds = DeepScan()
     path = os.path.expanduser('~')
     ds.add_search(path, '^Makefile$')
     ds.add_search(path, '~$')
     ds.add_search(path, 'bak$')
     ds.add_search(path, '^Thumbs.db$')
     ds.add_search(path, '^Thumbs.db:encryptable$')
     for ret in ds.scan():
         if True == ret:
             # it's yielding control to the GTK idle loop
             continue
         self.assert_(isinstance(ret, (str, unicode)),
                      "Expecting string but got '%s' (%s)" %
                      (ret, str(type(ret))))
         self.assert_(os.path.lexists(ret))
예제 #9
0
    def _test_encoding(self, fn):
        """Test encoding"""

        fullpath = self.write_file(fn)

        ds = DeepScan()
        ds.add_search(self.tempdir, '^%s$' % fn)
        found = False
        for ret in ds.scan():
            if True == ret:
                continue
            print(ret)
            self.assertEqual(ret, fullpath)
            found = True
        self.assertTrue(found, "Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assertNotExists(fullpath)
예제 #10
0
    def _test_encoding(self, fn):
        """Test encoding"""

        fullpath = self.write_file(fn)

        ds = DeepScan()
        ds.add_search(self.tempdir, '^%s$' % fn)
        found = False
        for ret in ds.scan():
            if True == ret:
                continue
            print(ret)
            self.assertEqual(ret, fullpath)
            found = True
        self.assertTrue(found, "Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assertNotExists(fullpath)
예제 #11
0
 def test_DeepScan(self):
     """Unit test for class DeepScan.  Preview real files."""
     ds = DeepScan()
     path = expanduser('~')
     ds.add_search(path, '^Makefile$')
     ds.add_search(path, '~$')
     ds.add_search(path, 'bak$')
     ds.add_search(path, '^Thumbs.db$')
     ds.add_search(path, '^Thumbs.db:encryptable$')
     try:
         for ret in ds.scan():
             if True == ret:
                 # it's yielding control to the GTK idle loop
                 continue
             self.assertLExists(ret)
     except UnicodeDecodeError:
         # Expectedly ds.scan() throws exception
         # when we have unicode paths and LANG==C.
         self.assertTrue(os.environ['LANG'] == 'C')
예제 #12
0
    def _test_encoding(self, fn):
        """Test encoding"""

        tempd = tempfile.mkdtemp(prefix='bleachbit-test-deepscan')
        self.assert_(os.path.exists(tempd))

        fullpath = os.path.join(tempd, fn)
        common.touch_file(fullpath)

        ds = DeepScan()
        ds.add_search(tempd, '^%s$' % fn)
        found = False
        for ret in ds.scan():
            if True == ret:
                continue
            self.assert_(ret == fullpath)
            found = True
        self.assert_(found, "Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assert_(not os.path.exists(fullpath))
        os.rmdir(tempd)
        self.assert_(not os.path.exists(tempd))
예제 #13
0
    def _test_encoding(self, fn):
        """Test encoding"""

        tempd = tempfile.mkdtemp(prefix='bleachbit-test-deepscan')
        self.assert_(os.path.exists(tempd))

        fullpath = os.path.join(tempd, fn)
        common.touch_file(fullpath)

        ds = DeepScan()
        ds.add_search(tempd, '^%s$' % fn)
        found = False
        for ret in ds.scan():
            if True == ret:
                continue
            self.assert_(ret == fullpath)
            found = True
        self.assert_(found, "Did not find '%s'" % fullpath)

        os.unlink(fullpath)
        self.assert_(not os.path.exists(fullpath))
        os.rmdir(tempd)
        self.assert_(not os.path.exists(tempd))