From d7a094a2e635bd51121c5d9b51ac0419dd120519 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Tue, 23 Aug 2022 22:58:34 +0300 Subject: 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 --- src/snakeoil/test/mixins.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/snakeoil/test/mixins.py b/src/snakeoil/test/mixins.py index 422b1bde..2c8abcad 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) -- cgit v1.2.3-65-gdbad