<commit_before>import os
from pathlib import Path
import sys

if 'VIRTUAL_ENV' in os.environ:
    major, minor = sys.version_info.major, sys.version_info.minor
    python = 'python{major}.{minor}'.format(major=major, minor=minor)
    envroot = Path(os.environ['VIRTUAL_ENV'])
    env_site_packages = envroot / 'lib' / python / 'site-packages'
    sys.path.append(str(env_site_packages))

import coverage
import nose

def main():
    python_path = str(Path(__file__).parent.parent)
    sys.path.append(python_path)
    nose.run(argv=[__file__])

if __name__ == '__main__':
    cov = coverage.coverage()
    cov.start()
    main()
    cov.stop()
    cov.save()<commit_msg>Moved test environment checks in run_tests.py<commit_after>import os
from pathlib import Path
import sys


# Add path for modules installed by pip

if 'VIRTUAL_ENV' in os.environ:
    major, minor = sys.version_info.major, sys.version_info.minor
    python = 'python{major}.{minor}'.format(major=major, minor=minor)
    envroot = Path(os.environ['VIRTUAL_ENV'])
    env_site_packages = envroot / 'lib' / python / 'site-packages'
    sys.path.append(str(env_site_packages))

import coverage
import nose


# Add blender repo path for tests module

blender_addon_repo_root_path = str(Path(__file__).parent.parent)
sys.path.append(blender_addon_repo_root_path)

from tests.utils import PREVIZ_API_ROOT_ENVVAR, PREVIZ_API_TOKEN_ENVVAR


def error_message():
    return '\n'.join(
        [
            '\n',
            78*'*',
            'Testing environment not set. Set the variables :',
            '\t-{}'.format(PREVIZ_API_ROOT_ENVVAR),
            '\t-{}'.format(PREVIZ_API_TOKEN_ENVVAR),
            78*'*',
            '\n'
        ]
    )

def is_environment_valid():
    def envvar_is_valid(envvar):
        return len(os.environ.get(envvar, '')) > 0
    
    return envvar_is_valid(PREVIZ_API_ROOT_ENVVAR) \
       and envvar_is_valid(PREVIZ_API_TOKEN_ENVVAR)

def main():
    cov = coverage.coverage()
    cov.start()
    nose.run(argv=[__file__])
    cov.stop()
    cov.save()

if __name__ == '__main__':
    if not is_environment_valid():
        print(error_message())
        raise EnvironmentError
    main()
{'fraction_non_alphanumeric': 0.12226277372262774, 'fraction_numerical': 0.002281021897810219, 'mean_word_length': 3.3084479371316307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5352066', 'n_tokens_mistral': 758, 'n_tokens_neox': 748, 'n_words': 149}