Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python 3.12 #236

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
python-version: '3.9'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -48,12 +50,18 @@ jobs:
run: |
pip install -r requirements.txt

- name: Test with pytest
- name: Test with pytest for Python <3.12
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
run: |
python -m pytest --cov-config=.coveragerc.${{ runner.os }}
if: matrix.python-version != '3.12'

- name: Test with pytest for Python 3.12
run: |
python -m pytest --cov-config=.coveragerc.python3.12 --ignore=audbackend/core/backend/artifactory.py --ignore=tests/test_backend_artifactory.py
if: matrix.python-version == '3.12'

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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',
]
dependencies = [
Expand All @@ -37,13 +38,13 @@ dynamic = ['version']

[project.optional-dependencies]
artifactory = [
'dohq-artifactory >=0.10.0',
'dohq-artifactory >=0.10.0; python_version < "3.12"',
]
minio = [
'minio',
]
all = [
'dohq-artifactory >=0.10.0',
'dohq-artifactory >=0.10.0; python_version < "3.12"',
'minio',
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"artifactory",
"artifactory",
f"unittest-{audeer.uid()[:8]}",
audbackend.backend.Artifactory,
pytest.importorskip("audbackend.backend.Artifactory"),
),
(
"minio",
Expand Down
21 changes: 21 additions & 0 deletions tests/test_backend_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,24 @@ def test_maven_file_structure(
assert path_expected == path
assert interface.ls(file) == [(file, version)]
assert interface.ls() == [(file, version)]


def test_errors(tmpdir):
r"""Test error for creating and opening backend.

Args:
tmpdir: tmpdir fixture

"""
host = audeer.mkdir(tmpdir, "backend")
repo = "repo"
backend = audbackend.backend.FileSystem(host, repo)
with pytest.raises(FileNotFoundError):
backend._open()
backend._create()
assert os.path.exists(os.path.join(host, repo))
backend._open()
backend._close()
with pytest.raises(FileExistsError):
backend._create()
backend._delete()
23 changes: 22 additions & 1 deletion tests/test_backend_minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,33 @@ def test_create_delete_repositories(host, repository):
@pytest.mark.parametrize("host", [pytest.HOSTS["minio"]])
@pytest.mark.parametrize("repository", [f"unittest-{pytest.UID}-{audeer.uid()[:8]}"])
@pytest.mark.parametrize("authentication", [("bad-access", "bad-secret")])
def test_errors(host, repository, authentication):
def test_errors_authentication(host, repository, authentication):
backend = audbackend.backend.Minio(host, repository, authentication=authentication)
with pytest.raises(audbackend.BackendError):
backend.open()


@pytest.mark.parametrize("host", [pytest.HOSTS["minio"]])
@pytest.mark.parametrize("repository", [f"unittest-{pytest.UID}-{audeer.uid()[:8]}"])
def test_errors(host, repository):
r"""Test error for creating and opening backend.

Args:
host: host
repository: repository

"""
backend = audbackend.backend.Minio(host, repository)
with pytest.raises(FileNotFoundError):
backend._open()
backend._create()
backend._open()
backend._close()
with pytest.raises(FileExistsError):
backend._create()
backend._delete()


def test_get_config(tmpdir, hosts, hide_credentials):
r"""Test parsing of configuration.

Expand Down
5 changes: 4 additions & 1 deletion tests/test_interface_unversioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

# Backend-interface combinations to use in all tests
backend_interface_combinations = [
(audbackend.backend.Artifactory, audbackend.interface.Unversioned),
(audbackend.backend.FileSystem, audbackend.interface.Unversioned),
(audbackend.backend.Minio, audbackend.interface.Unversioned),
(SingleFolder, audbackend.interface.Unversioned),
]
if hasattr(audbackend.backend, "Artifactory"):
backend_interface_combinations.append(
(audbackend.backend.Artifactory, audbackend.interface.Unversioned)
)
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="function", autouse=False)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_legacy_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

def test_legacy_import(hosts):
audbackend.Backend("host", "repo")
audbackend.Artifactory(hosts["artifactory"], "repo")
audbackend.FileSystem(hosts["file-system"], "repo")
if hasattr(audbackend, "Artifactory"):
audbackend.Artifactory(hosts["artifactory"], "repo")
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved
Loading