Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 17.9 — Capstone: Test, Package and Ship It
Python · Example 2 of 2

Write a pyproject.toml and verify it with tomllib

Delete the [project.scripts] section from the text and run again to see the problem list.

Finish docqa like a professional project: a test suite built on fakes, Ruff and a type checker, a pyproject.toml with a console command and a lock file, a Dockerfile, a README, and a list of what to build next.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a unittest test class with two tests for a function normalise(text) that lowercases and strips text, then run it with a TestResult and print the counts.

02

Use tomllib to read this text and print the project name and version: [project] newline name = "demo" newline version = "1.2.3".

03

Write a function has_secret(text, secret) and a test showing that describe_config-style output never contains the secret string.

Explain it without notes

01

How do fakes and dependency injection make the docqa test suite fast and deterministic?

02

What goes in pyproject.toml, and what does the lock file add?

03

What belongs in a good Dockerfile for a Python tool, and what must never be in the image?

04

Which checks would you run in CI for this project, and in what order?

05

How do pytest fixtures and parametrize improve a test suite compared with plain unittest classes?

Write a pyproject.toml and verify it with tomllib
Sign in to run this example in your browser.

Expected output

name: docqa | python: >=3.12
command 'docqa' runs: docqa.cli:main
runtime dependencies: ['numpy']
extras: ['dev', 'openai']
tools configured: ['mypy', 'pytest', 'ruff']
problems: none