Пример #1
0
def project_fixture(project_type):
    sources = get_sources(Settings().source_root).get(project_type)
    return pytest.fixture(
        scope='module',
        params=sources,
        ids=[source.name + source.extension for source in sources],
    )
Пример #2
0
def _download_language(language):
    sources_by_type = get_sources(
        path=os.path.join(Settings().source_root, language[0], language))
    if all([len(sources) <= 0 for _, sources in sources_by_type.items()]):
        _error_and_exit(f'No valid sources found for language: "{language}"')
    for project_type, sources in sources_by_type.items():
        for source in sources:
            _download_image_from_source(source)
Пример #3
0
def _download_project(project):
    sources_by_type = get_sources(Settings().source_root)
    try:
        Settings().verify_project_type(project)
        sources = sources_by_type[project]
        for source in sources:
            _download_image_from_source(source)
    except KeyError:
        _error_and_exit(f'No valid sources found for project: "{project}"')
Пример #4
0
def _download_source(source):
    sources_by_type = get_sources(Settings.source_root)
    for project_type, sources in sources_by_type.items():
        for src in sources:
            if f'{src.name}{src.extension}'.lower() == source.lower():
                _download_image_from_source(src)
                break
        else:  # If didn't break inner loop continue
            continue
        break  # Else break this loop as well
    else:
        _error_and_exit(f'Source "{source}" could not be found')
Пример #5
0
def _run_language(language):
    all_tests = _collect_tests()
    sources_by_type = get_sources(
        path=os.path.join('archive', language[0], language))
    if all([len(sources) <= 0 for _, sources in sources_by_type.items()]):
        _error_and_exit(f'No valid sources found for language: "{language}"')
    tests = []
    for project_type, sources in sources_by_type.items():
        for src in sources:
            tests.extend(_get_tests(project_type, all_tests, src))
    try:
        _verify_test_list_not_empty(tests)
        _run_pytest_and_exit(*tests)
    except KeyError:
        _error_and_exit(f'No tests found for sources in language "{language}"')
Пример #6
0
    def _collect_language_stats(self):
        language_stats = {}
        sources_by_type = get_sources(Settings().source_root)

        for project, sources in sources_by_type.items():
            display_name = self._get_project_display_name(project)
            for source in sources:
                if source.language not in language_stats:
                    language_stats[source.language] = {
                        p: ''
                        for p in self._projects
                    }
                    language_stats[source.language]['Name'] = source.language
                language_stats[source.language][
                    display_name] = f'{source.name}{source.extension}'

        return language_stats
Пример #7
0
def _run_source(source):
    all_tests = _collect_tests()
    sources_by_type = get_sources('archive')
    for project_type, sources in sources_by_type.items():
        for src in sources:
            filename = f'{src.name}{src.extension}'
            if filename.lower() == source.lower():
                tests = _get_tests(project_type, all_tests, src)
                try:
                    _verify_test_list_not_empty(tests)
                    _run_pytest_and_exit(*tests)
                except KeyError:
                    _error_and_exit(
                        f'No tests could be found for source "{source}"')
                break
        else:  # If didn't break inner loop continue
            continue
        break  # Else break this loop as well
    else:
        _error_and_exit(f'Source "{source}" could not be found')
Пример #8
0
def _download_all():
    sources_by_type = get_sources(Settings().source_root)
    for _, sources in sources_by_type.items():
        for source in sources:
            _download_image_from_source(source)