Skip to content

Commit

Permalink
Also test the file contents in TestUnpackArchives.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Oct 18, 2018
1 parent 7f3b2c1 commit 3f1f802
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Empty file.
24 changes: 16 additions & 8 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class TestUnpackArchives(object):
script_world.sh 601 script where world can execute
dir 744 directory
dir/dirfile 622 regular file
4) the file contents are extracted correctly (though the content of
each file isn't currently unique)
"""

Expand All @@ -297,19 +299,25 @@ def mode(self, path):
def confirm_files(self):
# expectations based on 022 umask set above and the unpack logic that
# sets execute permissions, not preservation
for fname, expected_mode, test in [
('file.txt', 0o644, os.path.isfile),
('symlink.txt', 0o644, os.path.isfile),
('script_owner.sh', 0o755, os.path.isfile),
('script_group.sh', 0o755, os.path.isfile),
('script_world.sh', 0o755, os.path.isfile),
('dir', 0o755, os.path.isdir),
(os.path.join('dir', 'dirfile'), 0o644, os.path.isfile)]:
for fname, expected_mode, test, expected_contents in [
('file.txt', 0o644, os.path.isfile, 'file\n'),
# We don't test the "symlink.txt" contents for now.
('symlink.txt', 0o644, os.path.isfile, None),
('script_owner.sh', 0o755, os.path.isfile, 'file\n'),
('script_group.sh', 0o755, os.path.isfile, 'file\n'),
('script_world.sh', 0o755, os.path.isfile, 'file\n'),
('dir', 0o755, os.path.isdir, None),
(os.path.join('dir', 'dirfile'), 0o644, os.path.isfile, ''),
]:
path = os.path.join(self.tempdir, fname)
if path.endswith('symlink.txt') and sys.platform == 'win32':
# no symlinks created on windows
continue
assert test(path), path
if expected_contents is not None:
with open(path) as f:
contents = f.read()
assert contents == expected_contents, 'fname: {}'.format(fname)
if sys.platform == 'win32':
# the permissions tests below don't apply in windows
# due to os.chmod being a noop
Expand Down

0 comments on commit 3f1f802

Please sign in to comment.