Skip to content

Commit

Permalink
fix: fixtures moved back to check files
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairshakoorarbisoft committed Dec 6, 2023
1 parent 24d291c commit abf7c38
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 66 deletions.
55 changes: 3 additions & 52 deletions pytest_repo_health/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions pytest_repo_health/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
Utilities for pytest plugin
"""

import codecs
import os
import re
from pathlib import Path

Expand Down Expand Up @@ -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()

0 comments on commit abf7c38

Please sign in to comment.