mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
## Description Migrate the first two Testcontainers getting-started guides from [testcontainers.com/guides](https://testcontainers.com/guides/) into the Docker docs site: - **Getting started with Testcontainers for Go** — multi-page guide with 4 chapters (create project, write tests, test suites, run tests). Code updated to testcontainers-go v0.41.0 API (`postgres.Run()`, `CleanupContainer`, `BasicWaitStrategies()`). - **Getting started with Testcontainers for Python** — multi-page guide with 3 chapters (create project, write tests, run tests). Code updated to testcontainers-python 4.14.2 (fixed `get_exposed_port()` returning `int`). Each guide appears as its own entry in the `/guides/` listing with proper language and tag filters (`testing-with-docker`). Chapters render with stepper navigation in the sidebar. Also adds: - A `testing-with-docker` tag to `data/tags.yaml` - A Claude skill (`.claude/skills/testcontainers-guides-migrator/SKILL.md`) that documents the repeatable migration process for the remaining 19 guides - Links from `content/manuals/testcontainers.md` to the new guides - Vale vocabulary entries for `pgx`, `Micronaut`, `psycopg`, `pytest` All guide code was compiled and tests verified passing in containers with Docker socket mounted. ## Related issues or tickets No related issues found. ## Reviews - [ ] Technical review - [ ] Editorial review - [ ] Product review
36 lines
1.2 KiB
Markdown
36 lines
1.2 KiB
Markdown
---
|
|
title: Getting started with Testcontainers for Python
|
|
linkTitle: Testcontainers for Python
|
|
description: Learn how to use Testcontainers for Python to test database interactions with a real PostgreSQL instance.
|
|
keywords: testcontainers, python, testing, postgresql, integration testing, pytest
|
|
summary: |
|
|
Learn how to create a Python application and test database interactions
|
|
using Testcontainers for Python with a real PostgreSQL instance.
|
|
toc_min: 1
|
|
toc_max: 2
|
|
tags: [testing-with-docker]
|
|
languages: [python]
|
|
params:
|
|
time: 15 minutes
|
|
---
|
|
|
|
<!-- Source: https://github.com/testcontainers/tc-guide-getting-started-with-testcontainers-for-python -->
|
|
|
|
In this guide, you will learn how to:
|
|
|
|
- Create a Python application that uses PostgreSQL to store customer data
|
|
- Use `psycopg` to interact with the database
|
|
- Write integration tests using `testcontainers-python` and `pytest`
|
|
- Manage container lifecycle with pytest fixtures
|
|
|
|
## Prerequisites
|
|
|
|
- Python 3.10+
|
|
- pip
|
|
- A Docker environment supported by Testcontainers
|
|
|
|
> [!NOTE]
|
|
> If you're new to Testcontainers, visit the
|
|
> [Testcontainers overview](https://testcontainers.com/getting-started/) to learn more about
|
|
> Testcontainers and the benefits of using it.
|