Skip to content

Commit e4d3e57

Browse files
add dependency test and tweak pre-commit config
1 parent a4c138f commit e4d3e57

6 files changed

Lines changed: 71 additions & 3 deletions

File tree

.github/workflows/_test-units.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,48 @@ jobs:
4646
pip install -e .[test]
4747
4848
- name: Unit testing with pytest
49-
env:
50-
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
5149
run: |
5250
pytest --cov mindee --cov-fail-under 87
51+
52+
pytest-lite:
53+
name: Run Unit Tests (Lite)
54+
timeout-minutes: 30
55+
strategy:
56+
matrix:
57+
os:
58+
- "ubuntu-22.04"
59+
- "windows-2022"
60+
python-version:
61+
- "3.10"
62+
- "3.11"
63+
- "3.12"
64+
- "3.13"
65+
- "3.14"
66+
runs-on: ${{ matrix.os }}
67+
steps:
68+
- uses: actions/checkout@v6
69+
with:
70+
submodules: recursive
71+
72+
- name: Set up Python ${{ matrix.python-version }}
73+
uses: actions/setup-python@v6
74+
with:
75+
python-version: ${{ matrix.python-version }}
76+
77+
- name: Cache dependencies
78+
uses: actions/cache@v5
79+
with:
80+
path: ~/.cache/pip
81+
key: ${{ runner.os }}-test-${{ hashFiles('pyproject.toml') }}
82+
restore-keys: |
83+
${{ runner.os }}-test-
84+
85+
- name: Install dependencies
86+
run: |
87+
python -m pip install pip
88+
pip install -e .[test]
89+
90+
- name: Unit testing with pytest
91+
run: |
92+
pytest -m lite
93+

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ repos:
2727
hooks:
2828
- id: pip-audit
2929
args: ["."]
30+
stages: [pre-push]
3031

3132
- repo: https://github.com/pre-commit/mirrors-mypy
3233
rev: v2.1.0
@@ -48,10 +49,12 @@ repos:
4849
language: system
4950
pass_filenames: false
5051
files: ^docs/.*$|^mindee/.*\.py$
52+
stages: [pre-push]
5153

5254
- id: sphinx-linkcheck
5355
name: Sphinx Linkcheck
5456
entry: make -C docs linkcheck
5557
language: system
5658
pass_filenames: false
5759
files: ^docs/.*$|^mindee/.*\.py$
60+
stages: [pre-push]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from mindee.error import MindeeError
22

33

4-
class MindeeDependencyError(MindeeError, RuntimeError):
4+
class MindeeDependencyError(MindeeError, ImportError):
55
"""An exception relating to missing dependencies."""

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ junit_family = "xunit2"
126126
markers = [
127127
"lineitems: debug line items",
128128
"integration: integration tests that send calls to the API - select with '-m integration'",
129+
"lite: tests for mindee-lite",
129130
"v2: tests specific to version 2 of the API",
130131
"pillow: tests that require the use of the Pillow (PIL) library",
131132
"pypdfium2: tests that require the usage of the pypdfium2 library"

tests/dependencies/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
3+
from mindee.dependencies import PILLOW_AVAILABLE, PYPDFIUM2_AVAILABLE
4+
5+
6+
@pytest.mark.pillow
7+
def test_pillow_installed():
8+
assert PILLOW_AVAILABLE
9+
10+
11+
@pytest.mark.pypdfium2
12+
def test_pypdfium2_installed():
13+
assert PYPDFIUM2_AVAILABLE
14+
15+
16+
@pytest.mark.lite
17+
def test_pillow_missing():
18+
assert not PILLOW_AVAILABLE
19+
20+
21+
@pytest.mark.lite
22+
def test_pypdfium2_missing():
23+
assert not PYPDFIUM2_AVAILABLE

0 commit comments

Comments
 (0)