Skip to content

Commit

Permalink
Add support for Python 3.12 (#479)
Browse files Browse the repository at this point in the history
* Add support for Python 3.12

* Skip Artifactory repo test for Python >=3.12

* Fix backend import

* Remove artifactory repos for 3.12

* Update expected error message

* Fix coverage
  • Loading branch information
hagenw authored Dec 5, 2024
1 parent bb9a15a commit 7584811
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
python-version: '3.9'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'
# Other pandas versions
- os: ubuntu-latest
python-version: '3.10'
Expand Down
4 changes: 2 additions & 2 deletions audb/core/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Repository:
}

if hasattr(audbackend.backend, "Artifactory"):
_backends["artifactory"] = audbackend.backend.Artifactory
_backends["artifactory"] = audbackend.backend.Artifactory # pragma: no cover

backend_registry = _backends
r"""Backend registry.
Expand Down Expand Up @@ -121,7 +121,7 @@ def create_backend_interface(self) -> type[audbackend.interface.Base]:
backend_class = self.backend_registry[self.backend]
backend = backend_class(self.host, self.name)
if self.backend == "artifactory":
interface = audbackend.interface.Maven(backend)
interface = audbackend.interface.Maven(backend) # pragma: no cover
else:
interface = audbackend.interface.Versioned(backend)
return interface
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ classifiers = [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering',
]
requires-python = '>=3.9'
Expand Down
10 changes: 7 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import glob
import os
import platform
import sys

import pytest

Expand Down Expand Up @@ -208,12 +209,15 @@ def private_and_public_repository():
public_artifactory_host = "https://audeering.jfrog.io/artifactory"
public_s3_host = "s3.dualstack.eu-north-1.amazonaws.com"
audb.config.REPOSITORIES = [
audb.Repository("data-private", public_artifactory_host, "artifactory"),
audb.Repository("audb-private", public_s3_host, "s3"),
audb.Repository("data-public", public_artifactory_host, "artifactory"),
audb.Repository("audb-public", public_s3_host, "s3"),
audb.Repository("data-public2", public_artifactory_host, "artifactory"),
]
if sys.version_info < (3, 12):
audb.config.REPOSITORIES += [
audb.Repository("data-private", public_artifactory_host, "artifactory"),
audb.Repository("data-public", public_artifactory_host, "artifactory"),
audb.Repository("data-public2", public_artifactory_host, "artifactory"),
]

yield repository

Expand Down
16 changes: 14 additions & 2 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import sys

import pytest

import audbackend

import audb


if hasattr(audbackend.backend, "Artifactory"):
artifactory_backend = audbackend.backend.Artifactory
else:
artifactory_backend = None


@pytest.mark.parametrize(
"repository1, repository2, expected",
[
Expand Down Expand Up @@ -70,12 +78,16 @@ def test_repository_repr(backend, host, repo, expected):
audbackend.backend.FileSystem,
audbackend.interface.Versioned,
),
(
pytest.param(
"artifactory",
"host",
"repo",
audbackend.backend.Artifactory,
artifactory_backend,
audbackend.interface.Maven,
marks=pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="No artifactory backend support in Python>=3.12",
),
),
],
)
Expand Down
5 changes: 1 addition & 4 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,7 @@ def test_database_iterator_error():
db = audformat.Database("db")
db["some"] = audformat.Table()
table = "some"
error_msg = (
"Can't instantiate abstract class DatabaseIterator "
"with abstract method _initialize_stream"
)
error_msg = "Can't instantiate abstract class DatabaseIterator"
with pytest.raises(TypeError, match=error_msg):
audb.DatabaseIterator(
db,
Expand Down

0 comments on commit 7584811

Please sign in to comment.