python-testing
Write and organize Python tests using pytest — fixtures, parametrize, mocking, and project-appropriate test structure
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Write and organize Python tests using pytest — fixtures, parametrize, mocking, and project-appropriate test structure
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Set up and manage GitHub Actions workflows that use Copilot coding agents for automated PR handling and issue resolution
Inspect active GitHub Actions workflows before commit or push, run matching local checks for staged or unpushed files, ask which missing tools to install via askQuestions, and fix in-scope issues so the Commit agent can proceed.
Write a commit message following the Conventional Commits specification with scope and body
Create an Architectural Decision Record (ADR) to document a significant design or technology choice
Audit VS Code extensions against the current project stack and recommend keep/add/remove actions
Diagnose and fix a failing CI pipeline or GitHub Actions workflow
SOC 직업 분류 기준
| name | python-testing |
| description | Write and organize Python tests using pytest — fixtures, parametrize, mocking, and project-appropriate test structure |
| compatibility | >=1.4 |
Skill metadata: version "1.0"; license MIT; tags [python, testing, pytest, unittest]; recommended tools [codebase, runCommands, editFiles].
Organize tests to mirror the source tree:
src/
mypackage/
auth.py
models.py
tests/
test_auth.py
test_models.py
conftest.py
test_<module>.py to match the source module.conftest.py for shared fixtures scoped to a directory.tests/integration/ and unit tests in tests/unit/ when both exist.Use fixtures for setup and teardown. Prefer function scope unless shared state is intentional:
@pytest.fixture
def db_session(tmp_path):
db = Database(tmp_path / "test.db")
yield db
db.close()
@pytest.fixture(autouse=True) unless project-wide.tmp_path (not tempfile) for temporary files.monkeypatch for environment variables and attribute patching.Use @pytest.mark.parametrize for data-driven tests:
@pytest.mark.parametrize("input_val,expected", [
("hello", 5),
("", 0),
(" spaces ", 10),
])
def test_string_length(input_val, expected):
assert len(input_val) == expected
unittest.mock.patch or monkeypatch — prefer monkeypatch for simple attribute/env patches.spec=True when patching classes to catch interface drift.assert statements — pytest rewrites them for detailed failure output.with pytest.raises(ValueError, match="expected message"):assert result == pytest.approx(3.14, abs=0.01)Prefer pyproject.toml for pytest configuration:
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --strict-markers --strict-config"
markers = [
"slow: marks tests as slow",
"integration: marks integration tests",
]
Run coverage alongside tests:
pytest --cov=src --cov-report=term-missing
# pragma: no cover sparingly and only with justification.