Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,87 @@
# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# Python
*.pyc
__pycache__/
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info/
dist/
build/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual Environment
venv/
env/
ENV/
.venv/
.ENV/

# Testing
.pytest_cache/
.coverage
htmlcov/
coverage.xml
*.cover
.hypothesis/
.tox/
.nox/

# Claude
.claude/*

# Database
*.db
*.sqlite
*.sqlite3
instance/

# Flask
instance/
.webassets-cache

# Logs
*.log

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Environment variables
.env
.env.local
.env.*.local

# Package managers
# Note: Don't ignore poetry.lock or uv.lock
node_modules/

# Misc
*.bak
.cache/
140 changes: 140 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
[tool.poetry]
name = "flask-blog"
version = "0.1.0"
description = "A Flask-based blog application"
authors = ["Your Name <[email protected]>"]
readme = "README.md"
packages = [{include = "app"}]

[tool.poetry.dependencies]
python = "^3.8.1"
Flask = "0.10.1"
Flask-Script = "2.0.5"
Flask-SQLAlchemy = "2.1"
Flask-Migrate = "1.7.0"
Flask-WTF = "0.12"
Flask-Bootstrap = "3.3.5.7"
WTForms = "2.1"
itsdangerous = "0.24"
Jinja2 = "2.8"
MarkupSafe = "0.23"
SQLAlchemy = "1.0.11"
Werkzeug = "0.11.3"
wheel = "0.24.0"
flask-login = "0.3.2"
flask-moment = "0.5.1"
ForgeryPy = "0.1"
gunicorn = "19.4.5"
psycopg2-binary = "2.9.9"

[tool.poetry.group.dev.dependencies]
pytest = "^6.2.0"
pytest-cov = "^3.0.0"
pytest-mock = "^3.6.0"
pytest-flask = "^1.2.0"

[tool.poetry.scripts]
test = "pytest:main"
tests = "pytest:main"

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"-ra",
"--strict-markers",
"--cov=app",
"--cov-branch",
"--cov-report=term-missing",
"--cov-report=html:htmlcov",
"--cov-report=xml:coverage.xml",
"--cov-fail-under=80",
"-vv",
"--tb=short",
"--maxfail=1",
]
markers = [
"unit: Unit tests",
"integration: Integration tests",
"slow: Slow running tests",
]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::PendingDeprecationWarning",
]

[tool.coverage.run]
source = ["app"]
branch = true
omit = [
"*/tests/*",
"*/migrations/*",
"*/__init__.py",
"*/config.py",
"*/manage.py",
]

[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = false
skip_empty = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.coverage.html]
directory = "htmlcov"

[tool.coverage.xml]
output = "coverage.xml"

[tool.isort]
profile = "black"
line_length = 88
known_first_party = ["app"]
skip_glob = ["*/migrations/*"]

[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| migrations
)/
'''

[tool.mypy]
python_version = "3.8"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
ignore_missing_imports = true
exclude = ["migrations/", "tests/"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 5 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest==6.2.5
pytest-cov==3.0.0
pytest-mock==3.6.1
pytest-flask==1.2.0
coverage[toml]==6.5.0
Empty file added tests/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import tempfile
import pytest


@pytest.fixture
def temp_dir():
"""Create a temporary directory."""
with tempfile.TemporaryDirectory() as tmpdir:
yield tmpdir


@pytest.fixture
def mock_config(monkeypatch):
"""Mock configuration values."""
def _mock_config(key, value):
monkeypatch.setattr(f'config.Config.{key}', value)
return _mock_config


@pytest.fixture(autouse=True)
def reset_environment(monkeypatch):
"""Reset environment variables for each test."""
monkeypatch.setenv('FLASK_CONFIG', 'testing')
monkeypatch.setenv('DATABASE_URL', 'sqlite:///:memory:')
Loading