def teardown_function():
    """Function which is run after each test in this file.

    ``remove_tmp_dir`` will do the following:
    1. Delete the directory called ``tmp`` (if already exists)

    Add any other things for teardown here.
    Note: this function gets run after each test, so files/data will not be saved
        in between tests.
    """
    remove_tmp_dir()
Exemple #2
0
def create_tmp_dir_multi_session():
    """Create a temporary directory for data related to multi-session unit tests and copy test data files.
    1. Remove the ``tmp`` directory if it exists.
    2. Copy the ``data_testing_multi`` directory to the ``tmp`` directory. Ignoring the `.git` folder within
    Any data files created during testing will go into ``tmp`` directory.
    This is created/removed for each test.
    """
    ignore_git_pattern = shutil.ignore_patterns(
        str(path_data_multi_sessions_contrasts_source / '.git'))
    remove_tmp_dir()
    Path(path_temp).mkdir()
    if Path(path_data_multi_sessions_contrasts_source).exists():
        shutil.copytree(path_data_multi_sessions_contrasts_source,
                        path_data_multi_sessions_contrasts_tmp,
                        ignore=ignore_git_pattern)
Exemple #3
0
def create_tmp_dir(copy_data_testing_dir=True):
    """Create a temporary directory for data_functional and copy test data files.

    1. Remove the ``tmp`` directory if it exists.
    2. Copy the ``data_functional_testing`` directory to the ``tmp`` directory.

    Any data files created during testing will go into ``tmp`` directory.
    This is created/removed for each test.

    Args:
        copy_data_testing_dir (bool): If true, copy the __data_testing_dir_ref__ folder
            into the ``tmp`` folder.
    """
    remove_tmp_dir()
    Path(path_temp).mkdir(parents=True, exist_ok=True)
    if Path(path_data_functional_source).exists() and copy_data_testing_dir:
        shutil.copytree(path_data_functional_source, path_data_functional_tmp)
Exemple #4
0
def create_tmp_dir(copy_data_testing_dir=True):
    """Create a temporary directory for unit_test data and copy test data files.

    1. Remove the ``tmp`` directory if it exists.
    2. Copy the ``data_testing`` directory to the ``tmp`` directory.

    Any data files created during testing will go into ``tmp`` directory.
    This is created/removed for each test.

    Args:
        copy_data_testing_dir (bool): If true, copy the __data_testing_dir_ref__ folder
            into the ``tmp`` folder.
    """
    remove_tmp_dir()
    os.mkdir(path_temp)
    if os.path.exists(path_data_testing_source) and copy_data_testing_dir:
        shutil.copytree(path_data_testing_source, path_data_testing_tmp)
Exemple #5
0
def teardown_function():
    remove_tmp_dir()