diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2022-08-23 22:58:34 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2022-08-24 19:25:24 +0300 |
commit | d7a094a2e635bd51121c5d9b51ac0419dd120519 (patch) | |
tree | 25d4109bbd4d9f4fd11a76f825c83169e66fab62 | |
parent | data_source: modernize tests (diff) | |
download | snakeoil-d7a094a2e635bd51121c5d9b51ac0419dd120519.tar.gz snakeoil-d7a094a2e635bd51121c5d9b51ac0419dd120519.tar.bz2 snakeoil-d7a094a2e635bd51121c5d9b51ac0419dd120519.zip |
test/mixins.py: remove TempDirMixin & tempdir_decorator
All last usages of TempDirMixin (in pkgcore) were removed, so finally we
can remove it. Same story with tempdir_decorator. If someone needs it,
please use ``tmp_path`` pytest fixture.
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/snakeoil/test/mixins.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/snakeoil/test/mixins.py b/src/snakeoil/test/mixins.py index 422b1bd..2c8abca 100644 --- a/src/snakeoil/test/mixins.py +++ b/src/snakeoil/test/mixins.py @@ -2,7 +2,6 @@ import errno import inspect import io import os -import shutil import stat import sys import tempfile @@ -11,38 +10,6 @@ from ..compatibility import IGNORED_EXCEPTIONS from . import TestCase -class TempDirMixin(TestCase): - - def setUp(self): - self.dir = tempfile.mkdtemp() - # force it, since sticky bits spread. - os.chmod(self.dir, 0o700) - - def tearDown(self): - # change permissions back or rmtree can't kill it - if not os.path.exists(self.dir): - return - for root, dirs, _files in os.walk(self.dir): - for directory in dirs: - os.chmod(os.path.join(root, directory), 0o700) - shutil.rmtree(self.dir) - -def tempdir_decorator(func): - def f(self, *args, **kwargs): - self.dir = tempfile.mkdtemp() - try: - os.chmod(self.dir, 0o700) - return func(self, *args, **kwargs) - finally: - if os.path.exists(self.dir): - for root, dirs, _files in os.walk(self.dir): - for directory in dirs: - os.chmod(os.path.join(root, directory), 0o777) - shutil.rmtree(self.dir) - f.__name__ = func.__name__ - return f - - def mk_named_tempfile(*args, **kwds): tmp_f = tempfile.NamedTemporaryFile(*args, **kwds) return io.TextIOWrapper(tmp_f) |