Beispiel #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)
Beispiel #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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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))
Beispiel #6
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))
    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)
Beispiel #8
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)
Beispiel #9
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')
Beispiel #10
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))
Beispiel #11
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))