Skip to content

Commit e4d1c78

Browse files
committed
test: Add pytest infrastructure and attachment tests
In making my last fix to attachments, I found it challenging not having tests to ensure there was no regression. Added pytest with minimal setup and isolated configuration. Created a separate test workflow to keep tests isolated from linting. Tests cover the key elements of the attachment logic: - URL extraction from issue bodies - Filename extraction from different URL types - Filename collision resolution - Manifest duplicate prevention
1 parent 7a9455d commit e4d1c78

File tree

5 files changed

+394
-0
lines changed

5 files changed

+394
-0
lines changed

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: "test"
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
pull_request:
7+
branches:
8+
- "*"
9+
push:
10+
branches:
11+
- "main"
12+
- "master"
13+
14+
jobs:
15+
test:
16+
name: test
17+
runs-on: ubuntu-24.04
18+
strategy:
19+
matrix:
20+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v5
25+
with:
26+
fetch-depth: 0
27+
- name: Setup Python
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
cache: "pip"
32+
- run: pip install -r release-requirements.txt
33+
- run: pytest tests/ -v

pytest.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[pytest]
2+
testpaths = tests
3+
python_files = test_*.py
4+
python_classes = Test*
5+
python_functions = test_*
6+
addopts = -v

release-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ colorama==0.4.6
88
docutils==0.22.3
99
flake8==7.3.0
1010
gitchangelog==3.0.4
11+
pytest==8.3.3
1112
idna==3.11
1213
importlib-metadata==8.7.0
1314
jaraco.classes==3.4.0

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Tests for python-github-backup."""

0 commit comments

Comments
 (0)