Python Project Structure - Two Ways to Configure the directories and pyproject.toml.
I focus on option 1 as it's often the most practical for a small project.
chapters
00:00 intro
01:00 simple project structure
01:45 proper structure , more nested
03:32 run pytest with uv
06:58 add vscode extension for pytest
08:08 using the src/utils.py functions in main
View the GitHub Example Code:
--------------------------------------------------
https://github.com/RGGH/my-project
Install UV package manager:
----------------------------------------------
https://docs.astral.sh/uv/getting-sta...
Option 1: Simple Project (no package build)
Good for learning, scripts, and small projects.
Option 2: Proper Python Package Layout
Used for professional projects and packages.
1. Create the Project
```bash
uv init my-project
cd my-project
```
```bash
uv add --dev pytest
```
Your tree now looks like:
```
my-project/
├── .python-version
├── .venv/
│ ├── bin/
│ ├── lib/
│ └── pyvenv.cfg
├── README.md
├── main.py
├── pyproject.toml
└── uv.lock
```
Configure pytest in pyproject.toml
Open `pyproject.toml` and add a `[tool.pytest.ini_options]` section:
```toml
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src"] # or.....just "." if you are doing option 1
```
`testpaths` — tells pytest where to look so it doesn't crawl everything.
`pythonpath` — adds `src/` to `sys.path` so imports like `from my_project.utils import ...` work without installing the package.
Tests
Write the Tests
Create `tests/test_utils.py`:
```python
tests/test_utils.py
import pytest
from my_project.utils import clamp, word_count, running_average
UV runs commands inside the managed environment automatically — no `source .venv/bin/activate` needed:
```bash
uv run pytest
#pytest #uv #pythonprojects
In questa pagina del sito puoi guardare il video online Python Project Structure : UV & Pytest | avoid module not found! della durata di ore minuti seconda in buona qualità , che l'utente ha caricato jobstr 23 giugno 2026, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 138 volte e gli è piaciuto 7 spettatori. Buona visione!