def test_tmp_dir(os_makedirs, os_listdir, randint,
                 mock_request, ismount, base_path):
    with patch("os.path.exists", return_value=True):
        with patch("os.path.ismount", return_value=ismount):
            path = temp_dir.temp_dir(mock_request)
    mock_request.addfinalizer.assert_called_once()
    expected_path = os.path.join(base_path, "allensdk_test_123457")
    os_makedirs.assert_called_once_with(expected_path)
    assert path == expected_path
    with patch("shutil.rmtree") as mock_rmtree:
        with patch("os.path.exists", return_value=True):
            with pytest.warns(UserWarning):
                # run the finalizer
                mock_request.addfinalizer.call_args[0][0]()
        mock_rmtree.assert_called_once_with(expected_path)
        mock_rmtree.reset_mock()
        with patch("os.path.exists", return_value=False):
            mock_request.addfinalizer.call_args[0][0]()
        mock_rmtree.assert_called_once_with(expected_path)
def test_tmp_dir(os_makedirs, os_listdir, randint, mock_request, ismount,
                 base_path):
    with patch("os.path.exists", return_value=True):
        with patch("os.path.ismount", return_value=ismount):
            path = temp_dir.temp_dir(mock_request)
    mock_request.addfinalizer.assert_called_once()
    expected_path = os.path.join(base_path, "allensdk_test_123457")
    os_makedirs.assert_called_once_with(expected_path)
    assert path == expected_path
    with patch("shutil.rmtree") as mock_rmtree:
        with patch("os.path.exists", return_value=True):
            with pytest.warns(UserWarning):
                # run the finalizer
                mock_request.addfinalizer.call_args[0][0]()
        mock_rmtree.assert_called_once_with(expected_path)
        mock_rmtree.reset_mock()
        with patch("os.path.exists", return_value=False):
            mock_request.addfinalizer.call_args[0][0]()
        mock_rmtree.assert_called_once_with(expected_path)
Beispiel #3
0
def fn_temp_dir(request):
    return temp_dir(request)
Beispiel #4
0
def md_temp_dir(request):
    return temp_dir(request)
Beispiel #5
0
def fn_temp_dir(request):
    return temp_dir(request)
Beispiel #6
0
def md_temp_dir(request):
    return temp_dir(request)