19058353d1b503bf186552ce971c10be047c8bd1,nilearn/tests/test_cache_mixin.py,,test_cache_shelving,#,184

Before Change




def test_cache_shelving():
    try:
        temp_dir = tempfile.mkdtemp()
        job_glob = os.path.join(temp_dir, "joblib", "nilearn", "tests",
                                "test_cache_mixin", "f", "*")
        mem = Memory(cachedir=temp_dir, verbose=0)
        res = cache_mixin.cache(f, mem, shelve=True)(2)
        assert_equal(res.get(), 2)
        assert_equal(len(glob.glob(job_glob)), 1)
        res = cache_mixin.cache(f, mem, shelve=True)(2)
        assert_equal(res.get(), 2)
        assert_equal(len(glob.glob(job_glob)), 1)
    finally:
        del mem
        shutil.rmtree(temp_dir, ignore_errors=True)

After Change




def test_cache_shelving():
    with tempfile.TemporaryDirectory() as temp_dir:
        joblib_dir = Path(
            temp_dir, "joblib", "nilearn", "tests", "test_cache_mixin", "f")
        mem = Memory(cachedir=temp_dir, verbose=0)
        res = cache_mixin.cache(f, mem, shelve=True)(2)
        assert_equal(res.get(), 2)
        assert_equal(len(_get_subdirs(joblib_dir)), 1)
        res = cache_mixin.cache(f, mem, shelve=True)(2)
        assert_equal(res.get(), 2)
        assert_equal(len(_get_subdirs(joblib_dir)), 1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: nilearn/nilearn
Commit Name: 19058353d1b503bf186552ce971c10be047c8bd1
Time: 2019-10-14
Author: jerome@dockes.org
File Name: nilearn/tests/test_cache_mixin.py
Class Name:
Method Name: test_cache_shelving


Project Name: nilearn/nilearn
Commit Name: 19058353d1b503bf186552ce971c10be047c8bd1
Time: 2019-10-14
Author: jerome@dockes.org
File Name: nilearn/tests/test_cache_mixin.py
Class Name:
Method Name: test_check_memory


Project Name: nilearn/nilearn
Commit Name: 19058353d1b503bf186552ce971c10be047c8bd1
Time: 2019-10-14
Author: jerome@dockes.org
File Name: nilearn/tests/test_cache_mixin.py
Class Name:
Method Name: test__safe_cache_dir_creation


Project Name: nilearn/nilearn
Commit Name: 19058353d1b503bf186552ce971c10be047c8bd1
Time: 2019-10-14
Author: jerome@dockes.org
File Name: nilearn/tests/test_cache_mixin.py
Class Name:
Method Name: test__safe_cache_flush