TST Fix leak in tmp folders in LFW test when pillow is missing
@@ -24,10 +24,10 @@ from sklearn.utils._testing import SkipTest
from sklearn.datasets.tests.test_common import check_return_X_y
-SCIKIT_LEARN_DATA = tempfile.mkdtemp(prefix="scikit_learn_lfw_test_")
-SCIKIT_LEARN_EMPTY_DATA = tempfile.mkdtemp(prefix="scikit_learn_empty_test_")
+SCIKIT_LEARN_DATA = None
+SCIKIT_LEARN_EMPTY_DATA = None
+LFW_HOME = None
-LFW_HOME = os.path.join(SCIKIT_LEARN_DATA, 'lfw_home')
FAKE_NAMES = [
'Abdelatif_Smith',
'Abhati_Kepler',
@@ -44,6 +44,14 @@ def setup_module():
if not pillow_installed:
raise SkipTest("PIL not installed.")
+ global SCIKIT_LEARN_DATA, SCIKIT_LEARN_EMPTY_DATA, LFW_HOME
+
+ SCIKIT_LEARN_DATA = tempfile.mkdtemp(prefix="scikit_learn_lfw_test_")
+ LFW_HOME = os.path.join(SCIKIT_LEARN_DATA, 'lfw_home')
+
+ SCIKIT_LEARN_EMPTY_DATA = tempfile.mkdtemp(
+ prefix="scikit_learn_empty_test_")
+
if not os.path.exists(LFW_HOME):
os.makedirs(LFW_HOME)
