diff options
author | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-12-09 17:38:34 +0000 |
---|---|---|
committer | Tristan Maat <tm@tlater.net> | 2019-12-10 12:41:10 +0000 |
commit | bb9045a1c1fa7d4d45041af4c0a892df9584a3be (patch) | |
tree | 41343f94e25cb8474e35d0a4b73465d6b440569e | |
parent | 4ad66cd51f36319feef0ed0824e303f3f64c7422 (diff) | |
download | buildstream-bb9045a1c1fa7d4d45041af4c0a892df9584a3be.tar.gz |
tests/sources/tar.py: Use `utils._force_rmtree` instead of chmod
While this is deep in our test suite, and should therefore never
create files that leak information, our code security linter
complains about setting broad file permissions.
We should really be using `utils._force_rmtree` here anyway, to stop
duplicating code, so that's what we do.
-rw-r--r-- | tests/sources/tar.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/tests/sources/tar.py b/tests/sources/tar.py index f5f3dde2d..c3621c152 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -2,7 +2,7 @@ # pylint: disable=redefined-outer-name import os -from shutil import copyfile, rmtree +from shutil import copyfile import subprocess import tarfile import tempfile @@ -10,6 +10,7 @@ import urllib.parse import pytest +from buildstream import utils from buildstream._exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import @@ -303,16 +304,7 @@ def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): result.assert_success() finally: - - # Make tmpdir deletable no matter what happens - def make_dir_writable(_fn, path, _excinfo): - os.chmod(os.path.dirname(path), 0o777) - if os.path.isdir(path): - os.rmdir(path) - else: - os.remove(path) - - rmtree(str(tmpdir), onerror=make_dir_writable) + utils._force_rmtree(str(tmpdir)) @pytest.mark.parametrize("server_type", ("FTP", "HTTP")) |