Skip to content

Commit

Permalink
make tox write coverage xml and fix a couple of paths inside tests to…
Browse files Browse the repository at this point in the history
… make pytest work outside the src dir
  • Loading branch information
tykling committed Apr 12, 2024
1 parent 04939ba commit 18b1cdc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test = [
"coverage==7.2.2",
"factory-boy==3.2.1",
"pytest-django==4.8.0",
"pytest-cov==5.0.0",
"tox==4.14.2",
]

Expand Down Expand Up @@ -139,5 +140,5 @@ legacy_tox_ini = """
pytest-randomly
django-stubs-ext
-e.[test]
commands = pytest
commands = pytest --cov=. --cov-report=xml --cov-report=html
"""
3 changes: 2 additions & 1 deletion src/files/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the files API."""
from django.conf import settings
from pathlib import Path

from django.urls import reverse
Expand Down Expand Up @@ -342,7 +343,7 @@ def test_file_download(self) -> None:
response = self.client.get(url)
assert response.status_code == 200
assert response["content-type"] == "image/png"
with Path("static_src/images/logo_wide_black_500_RGB.png").open("rb") as f:
with (settings.BASE_DIR / "static_src/images/logo_wide_black_500_RGB.png").open("rb") as f:
assert f.read() == response.getvalue()

def test_file_metadata_update(self) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/utils/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests base class."""
from django.conf import settings
import base64
import hashlib
import json
Expand Down Expand Up @@ -107,7 +108,7 @@ def get_access_token(cls, user) -> str: # noqa: ANN001
def file_upload( # noqa: PLR0913
self,
*,
filepath: str = "static_src/images/logo_wide_black_500_RGB.png",
filepath: str = settings.BASE_DIR / "static_src/images/logo_wide_black_500_RGB.png",
title: str = "some title",
file_license: str = "CC_ZERO_1_0",
attribution: str = "fotoarne",
Expand Down

0 comments on commit 18b1cdc

Please sign in to comment.