A professional testing framework for coding interview preparation.
# Create virtual environment (recommended)
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windows
# Install dependencies
pip install -r requirements.txtNote: Always activate the virtual environment before running tests!
CodingPractice/
├── solutions/ # Your solution implementations
├── tests/ # Test files
├── pytest.ini # Pytest configuration
└── requirements.txt # Dependencies
Make sure to activate the virtual environment first:
source venv/bin/activate # On macOS/LinuxThen run your tests:
# Run all tests
pytest
# Run specific test file
pytest tests/test_backtracking.py
# Run tests by marker (difficulty)
pytest -m easy
pytest -m medium
pytest -m hard
# Run tests by topic
pytest -m array
pytest -m string
pytest -m tree
# Run with coverage
pytest --cov=solutions --cov-report=html
# Watch mode (auto-run on file changes)
ptw- Create your solution in
solutions/directory - Create corresponding test in
tests/directory - Use pytest markers to tag difficulty and topic
Example:
import pytest
@pytest.mark.easy
@pytest.mark.array
def test_two_sum():
from solutions.two_sum import two_sum
assert two_sum([2, 7, 11, 15], 9) == [0, 1]# Format code
black solutions/ tests/
# Lint code
flake8 solutions/ tests/
# Type checking
mypy solutions/