1:dev/projects/protest/example.py
" ==========================================
" rcepre / portfolio
" dernière version : 2026
" ==========================================
audio/
·· README.md
·· reterraform.antres
·· space_dust.antres
·· the_junkyard_of_the_jettisoned.antres
blog/
·· apte.md
dev/
·· lab/
·· projects/
·· 42-school.md
·· experience.md
·· skills.md
hello-world.html
1"""ProTest -- real usage example."""
2
3import asyncio
4from pathlib import Path
5from typing import Annotated
6
7from protest import ProTestSession, fixture, Use, ForEach, From
8
9
10session = ProTestSession()
11
12
13@fixture(tags=["io"])
14async def workspace(tmp_path: Annotated[Path, Use(tmp_path)]):
15 d = tmp_path / "workspace"
16 d.mkdir()
17 yield d
18 # teardown: tmp_path cleanup is automatic
19
20
21@session.test()
22async def test_write_and_read(
23 ws: Annotated[Path, Use(workspace)],
24):
25 f = ws / "hello.txt"
26 f.write_text("protest")
27 assert f.read_text() == "protest"
28
29
30FORMATS = ForEach(["json", "yaml", "toml"])
31
32
33@session.test()
34async def test_config_extensions(
35 ext: Annotated[str, From(FORMATS)],
36 ws: Annotated[Path, Use(workspace)],
37):
38 config = ws / f"config.{ext}"
39 config.touch()
40 assert config.suffix == f".{ext}"
41
NORMALdev/projects/protest/example.py[+]
^E explorateur^R rendu^; thème
python41L1:1
github.com/renaudcepre
ENcatppuccin