From abf7c38ae4f8b28356577b1ab99e99be18467e9f Mon Sep 17 00:00:00 2001 From: zubairshakoorarbisoft Date: Wed, 6 Dec 2023 13:54:46 +0500 Subject: [PATCH] fix: fixtures moved back to check files --- pytest_repo_health/plugin.py | 55 ++---------------------------------- pytest_repo_health/utils.py | 14 --------- 2 files changed, 3 insertions(+), 66 deletions(-) diff --git a/pytest_repo_health/plugin.py b/pytest_repo_health/plugin.py index 4e110c0..c0e95fd 100644 --- a/pytest_repo_health/plugin.py +++ b/pytest_repo_health/plugin.py @@ -4,26 +4,20 @@ import datetime import os -import re -import requests -import tempfile import warnings from collections import defaultdict import pytest import yaml -from .utils import get_file_content, get_repo_remote_name +from .fixtures.git import git_origin_url, git_repo # pylint: disable=unused-import +from .fixtures.github import github_client, github_repo # pylint: disable=unused-import +from .utils import get_repo_remote_name session_data_holder_dict = defaultdict(dict) session_data_holder_dict["TIMESTAMP"] = datetime.datetime.now().date() -DJANGO_DEPS_SHEET_URL = ( - "https://docs.google.com/spreadsheets/d/19-BzpcX3XvqlazHcLhn1ZifBMVNund15EwY3QQM390M/export?format=csv" -) - - @pytest.fixture(autouse=True) def set_warnings() -> None: """Force asyncio mistakes to be errors""" @@ -146,30 +140,6 @@ def repo_path(request): return path -@pytest.fixture(name="setup_py") -def fixture_setup_py(repo_path): - """Fixture containing the text content of setup.py""" - full_path = os.path.join(repo_path, "setup.py") - return get_file_content(full_path) - - -@pytest.fixture(name="setup_cfg") -def fixture_setup_cfg(repo_path): - """Fixture containing the text content of setup.cfg""" - full_path = os.path.join(repo_path, "setup.cfg") - return get_file_content(full_path) - - -@pytest.fixture(name="python_versions_in_classifiers") -def fixture_python_version(setup_py): - """ - The list of python versions in setup.py classifiers - """ - regex_pattern = r"Programming Language :: Python :: ([\d\.]+)" - python_classifiers = re.findall(regex_pattern, setup_py, re.MULTILINE) - return python_classifiers - - @pytest.fixture def repo_health(request): """ @@ -182,25 +152,6 @@ def repo_health(request): return request.config.option.repo_health - - -@pytest.fixture(name='django_deps_sheet', scope="session") # pragma: no cover -def django_dependency_sheet_fixture(): - """ - Returns the path for csv file which contains django dependencies status. - Also, makes a request for latest sheet & dumps response into the csv file if request was successful. - """ - tmpdir = tempfile.mkdtemp() - csv_filepath = os.path.join(tmpdir, "django_dependencies_sheet.csv") - - res = requests.get(DJANGO_DEPS_SHEET_URL) - if res.status_code == 200: - with open(csv_filepath, 'w', encoding="utf8") as fp: - fp.write(res.text) - - return csv_filepath - - def pytest_ignore_collect(path, config): """ pytest hook that determines if pytest looks at specific file to collect tests diff --git a/pytest_repo_health/utils.py b/pytest_repo_health/utils.py index b8364c6..e962d20 100644 --- a/pytest_repo_health/utils.py +++ b/pytest_repo_health/utils.py @@ -1,9 +1,6 @@ """ Utilities for pytest plugin """ - -import codecs -import os import re from pathlib import Path @@ -43,14 +40,3 @@ def get_repo_remote_name(repo_path): return None match = re.fullmatch(URL_PATTERN, origin.url) return match.group("repo_name") - - -def get_file_content(path): - """ - Get the content of the UTF-8 text file at the specified path. - Used for pytest fixtures. - """ - if not os.path.exists(path): - return "" - with codecs.open(path, "r", "utf-8") as f: - return f.read()