Skip to content

Commit

Permalink
use importlib instead of deprecated pkg_resources. Add py 12 to test …
Browse files Browse the repository at this point in the history
…workflow
  • Loading branch information
vemonet committed Nov 28, 2023
1 parent 5b06317 commit a973cab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions src/rdflib_endpoint/sparql_router.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import re
from importlib import resources
from typing import Any, Callable, Dict, List, Optional, Union
from urllib import parse

import pkg_resources
import rdflib
from fastapi import APIRouter, Query, Request, Response
from fastapi.responses import JSONResponse
Expand Down Expand Up @@ -366,7 +366,7 @@ def serve_yasgui(self) -> Response:
"""Serve YASGUI interface"""
import json

with open(pkg_resources.resource_filename("rdflib_endpoint", "yasgui.html")) as f:
with resources.open_text("rdflib_endpoint", "yasgui.html") as f:
html_str = f.read()
html_str = html_str.replace("$TITLE", self.title)
html_str = html_str.replace("$DESCRIPTION", self.description)
Expand Down
17 changes: 8 additions & 9 deletions tests/test_serve_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import tempfile
from unittest.mock import MagicMock, patch

import pkg_resources
from click.testing import CliRunner

from rdflib_endpoint.__main__ import cli
Expand All @@ -19,7 +18,7 @@ def test_convert():
out_file = str(f"{tmp_file}.{out_format}")
result = runner.invoke(
cli,
["convert", pkg_resources.resource_filename("tests", "resources/test2.ttl"), "--output", out_file],
["convert", "tests/resources/test2.ttl", "--output", out_file],
)
assert result.exit_code == 0
with open(out_file) as file:
Expand All @@ -39,7 +38,7 @@ def test_convert_oxigraph():
"convert",
"--store",
"oxigraph",
pkg_resources.resource_filename("tests", "resources/test2.ttl"),
"tests/resources/test2.ttl",
"--output",
str(tmp_file),
],
Expand All @@ -64,9 +63,9 @@ def test_serve(mock_run: MagicMock) -> None:
cli,
[
"serve",
pkg_resources.resource_filename("tests", "resources/test.nq"),
pkg_resources.resource_filename("tests", "resources/test2.ttl"),
pkg_resources.resource_filename("tests", "resources/another.jsonld"),
"tests/resources/test.nq",
"tests/resources/test2.ttl",
"tests/resources/another.jsonld",
],
)
assert result.exit_code == 0
Expand All @@ -82,9 +81,9 @@ def test_serve_oxigraph(mock_run: MagicMock) -> None:
"serve",
"--store",
"oxigraph",
pkg_resources.resource_filename("tests", "resources/test.nq"),
pkg_resources.resource_filename("tests", "resources/test2.ttl"),
pkg_resources.resource_filename("tests", "resources/another.jsonld"),
"tests/resources/test.nq",
"tests/resources/test2.ttl",
"tests/resources/another.jsonld",
],
)
assert result.exit_code == 0

0 comments on commit a973cab

Please sign in to comment.