Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

python-testing

/python-testing

Pisze i naprawia testy w Pythonie na pytest: fixtury, parametryzację, mocki na granicy, testy asynchroniczne i pokrycie zmian.

Licencja
MIT
Ostatnia zmiana repozytorium
05.11.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze i naprawia testy w Pythonie na pytest: fixtury, parametryzację, mocki na granicy, testy asynchroniczne i pokrycie zmian.

Oryginalny opis (EN)

Python tests with pytest - layout, fixtures and conftest, parametrize, raises with match, tmp_path and monkeypatch, mocks with spec at the boundary, async tests, strict mode and warnings as errors, changed-lines coverage. Use when writing, fixing or setting up Python tests. Process and coverage threshold: tdd-workflow.

Jak działa

  1. Layout
  2. Writing tests
  3. Doubles
  4. Async
  5. Strictness
  6. Commands
Sekcje z nagłówków SKILL.md, w oryginale · 42 linii, 400 słów
Podgląd SKILL.md
---
name: python-testing
description: "Python tests with pytest - layout, fixtures and conftest, parametrize, raises with match, tmp_path and monkeypatch, mocks with spec at the boundary, async tests, strict mode and warnings as errors, changed-lines coverage. Use when writing, fixing or setting up Python tests. Process and coverage threshold: tdd-workflow."
---

# python-testing

Process and coverage threshold: `tdd-workflow`. Config (strict mode, warnings as errors, coverage): `python-tooling`.

## Layout

- Code in `src/<package>/`, tests in `tests/` outside it. Files `test_*.py`.
- Shared fixtures in `conftest.py` in the narrowest folder that needs them.

## Writing tests

- Plain `assert`; pytest shows the compared values on failure.
- Cases that differ only in data: one test with `@pytest.mark.parametrize`, readable names through `pytest.param(..., id="...")`. No loops over cases inside a test.
- Exceptions: `pytest.raises(ValueError, match="...")`; the `match` proves it is the expected failure.
- Fixtures for setup; teardown after `yield`; the narrowest scope that works; `autouse` only for safety nets that every test needs.
- Files in `tmp_path`; environment variables and attributes through `monkeypatch`. Never the real home directory, network or clock.

## Doubles

- Own code: real objects or simple fakes. Mocks only at the boundary (HTTP, message APIs, time).
- Mocks with a spec (`create_autospec`, `spec=`), so a wrong call or attribute fails.
- HTTP with httpx: hand the client an `httpx.MockTransport`; RESPX or pytest-httpx for complex cases. Don't patch the client's methods.
- A hand-written fake replaces the lowest boundary (the transport, `urlopen`), not your own wrapper around it: a fake of the wrapper keeps its old signature and passes after the wrapper and the code behind it stop matching. At least one test per outside service runs the real path down to that boundary.
- Time: pass a clock into the code, or patch the function it calls with `monkeypatch`.
- Dates in a local zone: add days to the local date, then attach the time. Days added to a UTC instant land an hour off when the clocks change.

## Async

- pytest-asyncio; in a project that uses only asyncio set `asyncio_mode = "auto"` in `[tool.pytest]`, which makes `async def` tests and fixtures run without markers.
- Projects on AnyIO: its own plugin (`anyio_mode = "auto"`); it conflicts with pytest-asyncio's auto mode, so never both.

## Strictness

- Unknown markers and config keys are errors; an `xfail` that passes fails the run, so a fixed bug forces the marker out.
- Warnings are errors; a test that expects one uses `pytest.warns`.

## Commands

- `uv run pytest -q`; one test: `uv run pytest tests/test_x.py::test_name`; stop at the first failure: `-x`.
- Coverage: `uv run pytest --cov`. Changed lines against the `tdd-workflow` threshold: `uv run diff-cover coverage.xml --compare-branch=origin/main --fail-under=<threshold>` after `--cov-report=xml`.

Wersje

RepozytoriumWynikLicencja
Ta strona · ssvinar/senior-agent-skills90MIT
microsoft/agent-framework100MIT
Sanit-mann/The-Insectoids100MIT
jelvodev/yaap100MIT
aeondave/malskill100MIT
sophophilix/agent-skills100MIT
laurigates/claude-plugins100MIT
dmitriyyukhanov/agent-plugins100MIT
affaan-m/ECC100MIT

Migawka bazy z 13.11.2026 · wersja paczki cd03ff4e9818 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95python-testing-patterns
    Podpowiada, jak pisać testy w Pythonie: fixtures, parametryzację, mocki, testy asynchroniczne i property-based.
  • 93pytest-patterns
    Pisze i porządkuje testy w pytest: fixtury, parametryzację, markery, conftest, mocki i ścieżki tymczasowe.
  • 100pytest-writing
    Pisze i przegląda testy pytest w idiomatycznym stylu: fixtury z właściwym zakresem, parametryzację i testy asynchroniczne.
  • 100python-pytest-ops
    Stosuje wzorce testowania pytest w Python: fixtures, markery, parametrize, mocki, conftest, pokrycie kodu oraz testy jednostkowe i integracyjne.
  • 100python-unit-tests
    Odpowiada na pytania o testy Python: fixtury, conftest, parametryzację, mockowanie, pokrycie i listę przypadków brzegowych.
  • 100testing-python
    Pomaga pisać i oceniać testy w pytest: fixtures, parametryzację, mocki, testy asynchroniczne i integrację z CI.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.