Allow specification of source file for archive tests.
This commit is contained in:
parent
1cb49aa296
commit
2ba54ee73a
|
@ -71,13 +71,14 @@ class ArchiveTest (unittest.TestCase):
|
||||||
patoolib._handle_archive(archive, 'test', program=self.program)
|
patoolib._handle_archive(archive, 'test', program=self.program)
|
||||||
patoolib._handle_archive(archive, 'test', program=self.program, verbose=True)
|
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."""
|
"""Test archive creation."""
|
||||||
# the file or directory to pack (note that they have spaces)
|
if not srcfile:
|
||||||
if singlefile:
|
if singlefile:
|
||||||
topack = os.path.join(datadir, 'foo .txt')
|
srcfile = os.path.join(datadir, 'foo .txt')
|
||||||
else:
|
else:
|
||||||
topack = os.path.join(datadir, 'foo dir')
|
srcfile = os.path.join(datadir, 'foo dir')
|
||||||
# The format and encoding arguments are needed for creating
|
# The format and encoding arguments are needed for creating
|
||||||
# archives with unusual file extensions.
|
# archives with unusual file extensions.
|
||||||
kwargs = dict(
|
kwargs = dict(
|
||||||
|
@ -85,9 +86,10 @@ class ArchiveTest (unittest.TestCase):
|
||||||
format=format,
|
format=format,
|
||||||
encoding=encoding,
|
encoding=encoding,
|
||||||
)
|
)
|
||||||
self._archive_create(filename, topack, kwargs)
|
self._archive_create(archive, srcfile, kwargs)
|
||||||
|
# create again in verbose mode
|
||||||
kwargs['verbose'] = True
|
kwargs['verbose'] = True
|
||||||
self._archive_create(filename, topack, kwargs)
|
self._archive_create(archive, srcfile, kwargs)
|
||||||
|
|
||||||
def _archive_create (self, filename, topack, kwargs):
|
def _archive_create (self, filename, topack, kwargs):
|
||||||
"""Create archive from filename."""
|
"""Create archive from filename."""
|
||||||
|
|
Loading…
Reference in New Issue