Skip to content

Commit

Permalink
Fix multi-Python version test issues (#45)
Browse files Browse the repository at this point in the history
* Fix missing images key in save tests

* disable fail fast

* Change CI branch triggers

* change usage of functools for py3.8

* Fix name of lint workflow

* fix lint workflow step

* lint

* fix tuple subscription

* change httpstatus usage

* Fix graphviz dep in rtd config
  • Loading branch information
freddyheppell authored Dec 16, 2024
1 parent 062a62c commit 55aa959
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
name: Test
name: Lint

on: [push, pull_request]
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

permissions:
contents: read

jobs:
test:
lint:
runs-on: ubuntu-latest

steps:
Expand All @@ -22,7 +30,7 @@ jobs:
run: poetry install --no-interaction --no-root
- name: Install Project
run: poetry install --no-interaction
- name: Poetry Build
- name: Ruff Lint Format
run: poetry run ruff format --check
id: format
- name: Ruff Lint Check
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Test

on: [push, pull_request]
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

permissions:
contents: read
Expand All @@ -10,6 +18,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

Expand Down
2 changes: 2 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ build:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"
apt_packages:
- graphviz
jobs:
post_create_environment:
# Install poetry
Expand Down
6 changes: 6 additions & 0 deletions tests/tree/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_page_to_dict(self, tree, tmp_path):
2009, 12, 17, 12, 4, 56, tzinfo=tzoffset(None, 7200)
),
"change_frequency": "monthly",
"images": None,
"news_story": None,
},
{
Expand All @@ -66,13 +67,15 @@ def test_page_to_dict(self, tree, tmp_path):
2009, 12, 17, 12, 4, 56, tzinfo=tzoffset(None, 7200)
),
"change_frequency": "always",
"images": None,
"news_story": None,
},
{
"url": "http://test_ultimate-sitemap-parser.com/news/foo.html",
"priority": Decimal("0.5"),
"last_modified": None,
"change_frequency": None,
"images": None,
"news_story": {
"title": "Foo <foo>",
"publish_date": datetime.datetime(
Expand All @@ -91,6 +94,7 @@ def test_page_to_dict(self, tree, tmp_path):
"priority": Decimal("0.5"),
"last_modified": None,
"change_frequency": None,
"images": None,
"news_story": {
"title": "Bar & bar",
"publish_date": datetime.datetime(
Expand All @@ -109,6 +113,7 @@ def test_page_to_dict(self, tree, tmp_path):
"priority": Decimal("0.5"),
"last_modified": None,
"change_frequency": None,
"images": None,
"news_story": {
"title": "Bar & bar",
"publish_date": datetime.datetime(
Expand All @@ -127,6 +132,7 @@ def test_page_to_dict(self, tree, tmp_path):
"priority": Decimal("0.5"),
"last_modified": None,
"change_frequency": None,
"images": None,
"news_story": {
"title": "Bąž",
"publish_date": datetime.datetime(
Expand Down
1 change: 1 addition & 0 deletions usp/fetch_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ class PagesXMLSitemapParser(AbstractXMLSitemapParser):

class Image:
"""Data class for holding image data while parsing."""

__slots__ = ["loc", "caption", "geo_location", "title", "license"]

def __init__(self):
Expand Down
9 changes: 5 additions & 4 deletions usp/objects/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
"""

import abc
from functools import cache
from functools import lru_cache
import os
import pickle
import tempfile
from typing import List, Iterator
from typing import List, Iterator, Tuple

from .page import SitemapPage


@cache
# TODO: change to functools.cache when dropping py3.8
@lru_cache(maxsize=None)
def _all_slots(target_cls):
mro = target_cls.__mro__

Expand Down Expand Up @@ -248,7 +249,7 @@ def __eq__(self, other) -> bool:
def __repr__(self):
return f"{self.__class__.__name__}(url={self.url}, pages={self.pages})"

def __getstate__(self) -> tuple[None, dict]:
def __getstate__(self) -> Tuple[None, dict]:
# Load slots of this class and its parents (mangling if appropriate)
obj_slots = {slot: getattr(self, slot) for slot in _all_slots(self.__class__)}
# Replace temp file path with actual content
Expand Down
2 changes: 1 addition & 1 deletion usp/web_client/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def status_code(self) -> int:
def status_message(self) -> str:
message = self.__requests_response.reason
if not message:
message = HTTPStatus(self.status_code(), None).phrase
message = HTTPStatus(self.status_code()).phrase
return message

def header(self, case_insensitive_name: str) -> Optional[str]:
Expand Down

0 comments on commit 55aa959

Please sign in to comment.