Test Python 3.8 (#470)

Signed-off-by: Glenn Jocher <[email protected]>
Co-authored-by: UltralyticsAssistant <[email protected]>
This commit is contained in:
Glenn Jocher
2025-05-26 15:40:23 +01:00
committed by GitHub
co-authored by UltralyticsAssistant
parent d4c1f9f7c1
commit 0a1c9b0703
4 changed files with 24 additions and 19 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest] # does not work with windows-latest
python-version: ["3.12", "3.13"]
python-version: ["3.8", "3.13"]
steps:
- uses: actions/checkout@v4
+1 -1
View File
@@ -22,4 +22,4 @@
# ├── test_summarize_pr.py
# └── ...
__version__ = "0.0.84"
__version__ = "0.0.85"
+2 -1
View File
@@ -3,6 +3,7 @@
import json
import os
from pathlib import Path
from typing import Union
import requests
@@ -95,7 +96,7 @@ class Action:
"""Checks if the repository is public using event data or GitHub API if needed."""
return self.event_data.get("repository", {}).get("private")
def get_username(self) -> str | None:
def get_username(self) -> Union[str, None]:
"""Gets username associated with the GitHub token."""
response = self.post(GITHUB_GRAPHQL_URL, json={"query": "query { viewer { login } }"})
if response.status_code == 200:
+20 -16
View File
@@ -1,10 +1,30 @@
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import sys
from unittest.mock import MagicMock, patch
import pytest
from actions.utils import Action, check_pypi_version, ultralytics_actions_info
@pytest.mark.skipif(sys.version_info < (3, 11), reason="tomllib requires Python 3.11+")
def test_check_pypi_version():
"""Test check_pypi_version function."""
with patch("tomllib.load", return_value={"project": {"name": "test-package", "version": "1.0.0"}}):
with patch("requests.get") as mock_get:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"info": {"version": "0.9.0"}}
mock_get.return_value = mock_response
local_version, online_version, publish = check_pypi_version()
assert local_version == "1.0.0"
assert online_version == "0.9.0"
assert publish is True
def test_action_init():
"""Test Action class initialization with default values."""
with patch.dict("os.environ", {"GITHUB_TOKEN": "test-token", "GITHUB_EVENT_NAME": "push"}):
@@ -41,22 +61,6 @@ def test_load_event_data():
assert data == {"test": "data"}
def test_check_pypi_version():
"""Test check_pypi_version function."""
with patch("tomllib.load", return_value={"project": {"name": "test-package", "version": "1.0.0"}}):
with patch("requests.get") as mock_get:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"info": {"version": "0.9.0"}}
mock_get.return_value = mock_response
local_version, online_version, publish = check_pypi_version()
assert local_version == "1.0.0"
assert online_version == "0.9.0"
assert publish is True
def test_ultralytics_actions_info():
"""Test ultralytics_actions_info function."""
with patch("actions.utils.github_utils.Action.print_info") as mock_print_info: