From 3f1f802f2243bf498509405972116910d9cbc96c Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Tue, 16 Oct 2018 20:23:35 -0700 Subject: [PATCH] Also test the file contents in TestUnpackArchives. --- ...BB707A-F48C-4FC9-8459-9B23C2D07FBE.trivial | 0 tests/unit/test_utils.py | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 news/B4BB707A-F48C-4FC9-8459-9B23C2D07FBE.trivial diff --git a/news/B4BB707A-F48C-4FC9-8459-9B23C2D07FBE.trivial b/news/B4BB707A-F48C-4FC9-8459-9B23C2D07FBE.trivial new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 591c8ab54c0..87b6cb6e49b 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -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) """ @@ -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