Skip to content

Commit 0a30425

Browse files
committed
new: Add pytest suite
1 parent 9348370 commit 0a30425

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed

.github/workflows/pytest.yml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# This file is autogenerated by maturin v1.9.4
2+
# To update, run
3+
#
4+
# maturin generate-ci github --pytest -m python/Cargo.toml -o .github/workflows/pytest.yml
5+
#
6+
name: CI
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
- master
13+
tags:
14+
- '*'
15+
pull_request:
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
linux:
23+
runs-on: ${{ matrix.platform.runner }}
24+
strategy:
25+
matrix:
26+
platform:
27+
- runner: ubuntu-22.04
28+
target: x86_64
29+
- runner: ubuntu-22.04
30+
target: x86
31+
- runner: ubuntu-22.04
32+
target: aarch64
33+
- runner: ubuntu-22.04
34+
target: armv7
35+
- runner: ubuntu-22.04
36+
target: s390x
37+
- runner: ubuntu-22.04
38+
target: ppc64le
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-python@v5
42+
with:
43+
python-version: 3.x
44+
- name: Build wheels
45+
uses: PyO3/maturin-action@v1
46+
with:
47+
target: ${{ matrix.platform.target }}
48+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
49+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50+
manylinux: auto
51+
- name: Upload wheels
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: wheels-linux-${{ matrix.platform.target }}
55+
path: dist
56+
- name: pytest
57+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
58+
shell: bash
59+
run: |
60+
set -e
61+
python3 -m venv .venv
62+
source .venv/bin/activate
63+
pip install pyfaup-rs --find-links dist --force-reinstall
64+
pip install pytest
65+
cd python && pytest
66+
- name: pytest
67+
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
68+
uses: uraimo/run-on-arch-action@v2
69+
with:
70+
arch: ${{ matrix.platform.target }}
71+
distro: ubuntu22.04
72+
githubToken: ${{ github.token }}
73+
install: |
74+
apt-get update
75+
apt-get install -y --no-install-recommends python3 python3-pip
76+
pip3 install -U pip pytest
77+
run: |
78+
set -e
79+
pip3 install pyfaup-rs --find-links dist --force-reinstall
80+
cd python && pytest
81+
82+
musllinux:
83+
runs-on: ${{ matrix.platform.runner }}
84+
strategy:
85+
matrix:
86+
platform:
87+
- runner: ubuntu-22.04
88+
target: x86_64
89+
- runner: ubuntu-22.04
90+
target: x86
91+
- runner: ubuntu-22.04
92+
target: aarch64
93+
- runner: ubuntu-22.04
94+
target: armv7
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-python@v5
98+
with:
99+
python-version: 3.x
100+
- name: Build wheels
101+
uses: PyO3/maturin-action@v1
102+
with:
103+
target: ${{ matrix.platform.target }}
104+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
105+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
106+
manylinux: musllinux_1_2
107+
- name: Upload wheels
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-musllinux-${{ matrix.platform.target }}
111+
path: dist
112+
- name: pytest
113+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
114+
uses: addnab/docker-run-action@v3
115+
with:
116+
image: alpine:latest
117+
options: -v ${{ github.workspace }}:/io -w /io
118+
run: |
119+
set -e
120+
apk add py3-pip py3-virtualenv
121+
python3 -m virtualenv .venv
122+
source .venv/bin/activate
123+
pip install pyfaup-rs --no-index --find-links dist --force-reinstall
124+
pip install pytest
125+
cd python && pytest
126+
- name: pytest
127+
if: ${{ !startsWith(matrix.platform.target, 'x86') }}
128+
uses: uraimo/run-on-arch-action@v2
129+
with:
130+
arch: ${{ matrix.platform.target }}
131+
distro: alpine_latest
132+
githubToken: ${{ github.token }}
133+
install: |
134+
apk add py3-virtualenv
135+
run: |
136+
set -e
137+
python3 -m virtualenv .venv
138+
source .venv/bin/activate
139+
pip install pytest
140+
pip install pyfaup-rs --find-links dist --force-reinstall
141+
cd python && pytest
142+
143+
windows:
144+
runs-on: ${{ matrix.platform.runner }}
145+
strategy:
146+
matrix:
147+
platform:
148+
- runner: windows-latest
149+
target: x64
150+
- runner: windows-latest
151+
target: x86
152+
steps:
153+
- uses: actions/checkout@v4
154+
- uses: actions/setup-python@v5
155+
with:
156+
python-version: 3.x
157+
architecture: ${{ matrix.platform.target }}
158+
- name: Build wheels
159+
uses: PyO3/maturin-action@v1
160+
with:
161+
target: ${{ matrix.platform.target }}
162+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
163+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
164+
- name: Upload wheels
165+
uses: actions/upload-artifact@v4
166+
with:
167+
name: wheels-windows-${{ matrix.platform.target }}
168+
path: dist
169+
- name: pytest
170+
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
171+
shell: bash
172+
run: |
173+
set -e
174+
python3 -m venv .venv
175+
source .venv/Scripts/activate
176+
pip install pyfaup-rs --find-links dist --force-reinstall
177+
pip install pytest
178+
cd python && pytest
179+
180+
macos:
181+
runs-on: ${{ matrix.platform.runner }}
182+
strategy:
183+
matrix:
184+
platform:
185+
- runner: macos-13
186+
target: x86_64
187+
- runner: macos-14
188+
target: aarch64
189+
steps:
190+
- uses: actions/checkout@v4
191+
- uses: actions/setup-python@v5
192+
with:
193+
python-version: 3.x
194+
- name: Build wheels
195+
uses: PyO3/maturin-action@v1
196+
with:
197+
target: ${{ matrix.platform.target }}
198+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
199+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
200+
- name: Upload wheels
201+
uses: actions/upload-artifact@v4
202+
with:
203+
name: wheels-macos-${{ matrix.platform.target }}
204+
path: dist
205+
- name: pytest
206+
run: |
207+
set -e
208+
python3 -m venv .venv
209+
source .venv/bin/activate
210+
pip install pyfaup-rs --find-links dist --force-reinstall
211+
pip install pytest
212+
cd python && pytest
213+
214+
sdist:
215+
runs-on: ubuntu-latest
216+
steps:
217+
- uses: actions/checkout@v4
218+
- name: Build sdist
219+
uses: PyO3/maturin-action@v1
220+
with:
221+
command: sdist
222+
args: --out dist --manifest-path python/Cargo.toml
223+
- name: Upload sdist
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: wheels-sdist
227+
path: dist
228+
229+
release:
230+
name: Release
231+
runs-on: ubuntu-latest
232+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
233+
needs: [linux, musllinux, windows, macos, sdist]
234+
permissions:
235+
# Use to sign the release artifacts
236+
id-token: write
237+
# Used to upload release artifacts
238+
contents: write
239+
# Used to generate artifact attestation
240+
attestations: write
241+
steps:
242+
- uses: actions/download-artifact@v4
243+
- name: Generate artifact attestation
244+
uses: actions/attest-build-provenance@v2
245+
with:
246+
subject-path: 'wheels-*/*'
247+
- name: Publish to PyPI
248+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
249+
uses: PyO3/maturin-action@v1
250+
env:
251+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
252+
with:
253+
command: upload
254+
args: --non-interactive --skip-existing wheels-*/*

python/tests/test_pyfaup.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
3+
from __future__ import annotations
4+
5+
import unittest
6+
7+
from pyfaup import Url
8+
9+
10+
class TestPyFaupRR(unittest.TestCase):
11+
12+
def test_url(self) -> None:
13+
parsed_url = Url('https://user:pass@sub.example.com:8080/path?query=value#fragment')
14+
15+
self.assertEqual(parsed_url.scheme, 'https')
16+
self.assertEqual(parsed_url.username, 'user')
17+
self.assertEqual(parsed_url.password, 'pass')
18+
self.assertEqual(parsed_url.host, 'sub.example.com')
19+
self.assertEqual(parsed_url.subdomain, 'sub')
20+
self.assertEqual(parsed_url.domain, 'example.com')
21+
self.assertEqual(parsed_url.suffix, 'com')
22+
self.assertEqual(parsed_url.port, 8080)
23+
self.assertEqual(parsed_url.path, '/path')
24+
self.assertEqual(parsed_url.query, 'query=value')
25+
self.assertEqual(parsed_url.fragment, 'fragment')

0 commit comments

Comments
 (0)