From 2ba54ee73a6ae3443e190a0b37065055025478c9 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 17 May 2012 11:27:03 +0200 Subject: [PATCH] Allow specification of source file for archive tests. --- tests/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 997500b..c0e01b0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -71,13 +71,14 @@ class ArchiveTest (unittest.TestCase): patoolib._handle_archive(archive, 'test', program=self.program) patoolib._handle_archive(archive, 'test', program=self.program, verbose=True) - def archive_create (self, filename, singlefile=False, format=None, encoding=None): + def archive_create (self, archive, srcfile=None, singlefile=False, + format=None, encoding=None): """Test archive creation.""" - # the file or directory to pack (note that they have spaces) - if singlefile: - topack = os.path.join(datadir, 'foo .txt') - else: - topack = os.path.join(datadir, 'foo dir') + if not srcfile: + if singlefile: + srcfile = os.path.join(datadir, 'foo .txt') + else: + srcfile = os.path.join(datadir, 'foo dir') # The format and encoding arguments are needed for creating # archives with unusual file extensions. kwargs = dict( @@ -85,9 +86,10 @@ class ArchiveTest (unittest.TestCase): format=format, encoding=encoding, ) - self._archive_create(filename, topack, kwargs) + self._archive_create(archive, srcfile, kwargs) + # create again in verbose mode kwargs['verbose'] = True - self._archive_create(filename, topack, kwargs) + self._archive_create(archive, srcfile, kwargs) def _archive_create (self, filename, topack, kwargs): """Create archive from filename."""