Skip to content

Latest commit

 

History

History
147 lines (98 loc) · 2.56 KB

File metadata and controls

147 lines (98 loc) · 2.56 KB

🐍 Python data structures, algorithms, and design patterns

CI Python TDD

A Test‑Driven Development (TDD) playground for Python.

Implementations of classic data structures and algorithms in Python with unit tests, complexity analysis, and practical examples.

🗂 Project Structure

python-data-structures-and-algorithms
│
├── common/
├── data_structures/
├── algorithms/
│   ├── sorting/
│   ├── searching/
│   ├── graph/
│   └── dynamic_programming/
│
├── tests/
├── benchmarks/
└── pyproject.toml
└── README.md
└── requirements.txt
  • src/ contains production code
  • tests/ mirrors the same structure and contains all unit tests

🛠 Requirements

  • Python ≥ 3.x
  • pip

Recommended Tools


🚀 Getting Started

Create and activate a virtual environment (recommended):

python -m venv venv
source venv/bin/activate  # Linux / macOS
venv\Scripts\activate     # Windows

Install dependencies:

pip install -r requirements.txt

Update dependencies

python  -m pip install -r requirements.txt --upgrade

🧪 Running Tests

Run all tests:

pytest

Stop after the first failure:

pytest -x

Run a single test file:

pytest tests/algorithms/strings/test_stringutil.py

Run test from a venv:

.\.venv\Scripts\python.exe -m pytest

📊 Code Coverage

Run code coverage:

coverage run --source=src -m pytest
coverage report

Generate an HTML report:

coverage html

Using pytest-cov (recommended)

pytest-cov also reports files without tests:

pytest --cov=src tests/
pytest --cov=src tests/ --cov-report=html

Run tests and update coverage

pytest --cov=your_package --cov-report=term-missing --cov-report=html

🔍 Static Analysis (pylint)

Run pylint on source and tests (ignoring missing docstrings):

pylint src --disable=missing-docstring
pylint tests --disable=missing-docstring

📦 Managing Dependencies

Update requirements.txt:

pip freeze > requirements.txt