<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_get_user_config
--------------------

Tests formerly known from a unittest residing in test_config.py named
"""

import pytest


@pytest.fixture(scope='function')
def back_up_rc(request):
    """
    Back up an existing cookiecutter rc and restore it after the test.
    If ~/.cookiecutterrc is pre-existing, move it to a temp location
    """
    self.user_config_path = os.path.expanduser('~/.cookiecutterrc')
    self.user_config_path_backup = os.path.expanduser(
        '~/.cookiecutterrc.backup'
    )

    if os.path.exists(self.user_config_path):
        shutil.copy(self.user_config_path, self.user_config_path_backup)
        os.remove(self.user_config_path)

    def restore_rc():
        """
        If it existed, restore ~/.cookiecutterrc
        """
        if os.path.exists(self.user_config_path_backup):
            shutil.copy(self.user_config_path_backup, self.user_config_path)
            os.remove(self.user_config_path_backup)
    request.addfinalizer(restore_rc)<commit_msg>Remove self references from setup/teardown<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_get_user_config
--------------------

Tests formerly known from a unittest residing in test_config.py named
"""

import os
import shutil
import pytest


@pytest.fixture(scope='function')
def back_up_rc(request):
    """
    Back up an existing cookiecutter rc and restore it after the test.
    If ~/.cookiecutterrc is pre-existing, move it to a temp location
    """
    user_config_path = os.path.expanduser('~/.cookiecutterrc')
    user_config_path_backup = os.path.expanduser(
        '~/.cookiecutterrc.backup'
    )

    if os.path.exists(user_config_path):
        shutil.copy(user_config_path, user_config_path_backup)
        os.remove(user_config_path)

    def restore_rc():
        """
        If it existed, restore ~/.cookiecutterrc
        """
        if os.path.exists(user_config_path_backup):
            shutil.copy(user_config_path_backup, user_config_path)
            os.remove(user_config_path_backup)
    request.addfinalizer(restore_rc)
{'fraction_non_alphanumeric': 0.12365842277181521, 'fraction_numerical': 0.0009332711152589828, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4713636', 'n_tokens_mistral': 686, 'n_tokens_neox': 678, 'n_words': 137}