diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-06 12:38:26 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-10-06 12:38:26 +0200 |
commit | 3a830854f0b538e918524d3b28c9f881b2422793 (patch) | |
tree | 231e090ccc8c8e64be448bb3fa669c7113c8c6f8 | |
parent | b17c0b0800210d32e270d1011f916284f272f541 (diff) | |
parent | aa9c2c5561e1793777d773ef7cd5b251f2db2789 (diff) | |
download | logilab-common-3a830854f0b538e918524d3b28c9f881b2422793.tar.gz |
backport stable
-rw-r--r-- | fileutils.py | 5 | ||||
-rw-r--r-- | test/unittest_fileutils.py | 8 | ||||
-rw-r--r-- | test/unittest_testlib.py | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/fileutils.py b/fileutils.py index 807f2b5..aacd801 100644 --- a/fileutils.py +++ b/fileutils.py @@ -36,7 +36,7 @@ from cStringIO import StringIO from logilab.common import STD_BLACKLIST as BASE_BLACKLIST, IGNORED_EXTENSIONS from logilab.common.shellutils import find -from logilab.common.compat import FileIO +from logilab.common.compat import FileIO, any def first_level_directory(path): """Return the first level directory of a path. @@ -377,7 +377,8 @@ def export(from_dir, to_dir, mkdir(dest) for filename in filenames: # don't include binary files - if filename.endswith(ignore_ext): + # endswith does not accept tuple in 2.4 + if any(filename.endswith(ext) for ext in ignore_ext): continue src = join(directory, filename) dest = to_dir + src[len(from_dir):] diff --git a/test/unittest_fileutils.py b/test/unittest_fileutils.py index d900b3f..b76196f 100644 --- a/test/unittest_fileutils.py +++ b/test/unittest_fileutils.py @@ -25,7 +25,7 @@ from logilab.common.testlib import TestCase, unittest_main, unittest from logilab.common.fileutils import * -DATA_DIR = 'data' +DATA_DIR = join(os.path.abspath(os.path.dirname(__file__)), 'data') NEWLINES_TXT = join(DATA_DIR,'newlines.txt') @@ -72,7 +72,7 @@ class ExportTC(TestCase): os.mkdir(self.tempdir) def test(self): - export('data', self.tempdir, verbose=0) + export(DATA_DIR, self.tempdir, verbose=0) self.assert_(exists(join(self.tempdir, '__init__.py'))) self.assert_(exists(join(self.tempdir, 'sub'))) self.assert_(not exists(join(self.tempdir, '__init__.pyc'))) @@ -83,8 +83,8 @@ class ExportTC(TestCase): class ProtectedFileTC(TestCase): def setUp(self): - self.rpath = 'data/write_protected_file.txt' - self.rwpath = 'data/normal_file.txt' + self.rpath = join(DATA_DIR, 'write_protected_file.txt') + self.rwpath = join(DATA_DIR, 'normal_file.txt') # Make sure rpath is not writable ! os.chmod(self.rpath, 33060) # Make sure rwpath is writable ! diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py index a458e77..2bb09a5 100644 --- a/test/unittest_testlib.py +++ b/test/unittest_testlib.py @@ -267,7 +267,7 @@ class TestlibTC(TestCase): tc = MyTC('test_1') self.assertEqual(tc.datapath('bar'), join('foo', 'bar')) # instance's custom datadir - self.skipTest('should this really works?') + self.skipTest('should this really work?') tc.datadir = 'spam' self.assertEqual(tc.datapath('bar'), join('spam', 'bar')) |