@@ -18,6 +18,7 @@ uv sync --extra test
1818```
1919
2020This will:
21+
2122- Start PostgreSQL 16 in Docker on port 5433
2223- Create the ` devbin_test ` database
2324- Wait for the database to be ready
@@ -83,10 +84,10 @@ docker-compose -f docker-compose.test.yml logs -f
8384Tests use environment variables from ` pytest.ini ` by default:
8485
8586``` ini
86- APP_DATABASE_URL = postgresql+asyncpg://postgres:postgres@localhost:5433/devbin_test
87- APP_BASE_FOLDER_PATH = /tmp/devbin_test_files
88- APP_DEBUG = true
89- APP_ALLOW_CORS_WILDCARD = true
87+ APP_DATABASE_URL = postgresql+asyncpg://postgres:postgres@localhost:5433/devbin_test
88+ APP_BASE_FOLDER_PATH = /tmp/devbin_test_files
89+ APP_DEBUG = true
90+ APP_ALLOW_CORS_WILDCARD = true
9091```
9192
9293You can override these by setting environment variables before running tests:
@@ -172,9 +173,9 @@ open htmlcov/index.html # or xdg-open on Linux
172173
173174- Overall: 80%+ (enforced in CI)
174175- Critical modules: 90%+
175- - ` app/services/paste_service.py `
176- - ` app/utils/token_utils.py `
177- - ` app/api/subroutes/pastes.py `
176+ - ` app/services/paste_service.py `
177+ - ` app/utils/token_utils.py `
178+ - ` app/api/subroutes/pastes.py `
178179
179180## Troubleshooting
180181
@@ -183,6 +184,7 @@ open htmlcov/index.html # or xdg-open on Linux
183184** Problem** : ` connection refused ` or ` could not connect to server `
184185
185186** Solution** :
187+
1861881 . Check if test database is running: ` docker ps | grep devbin_test `
1871892 . Start database: ` ./scripts/setup_test_db.sh `
1881903 . Check database logs: ` docker-compose -f docker-compose.test.yml logs `
@@ -192,6 +194,7 @@ open htmlcov/index.html # or xdg-open on Linux
192194** Problem** : Port 5433 is already in use
193195
194196** Solution** :
197+
1951981 . Change port in ` docker-compose.test.yml `
1961992 . Update ` pytest.ini ` to match
1972003 . Restart database
@@ -201,6 +204,7 @@ open htmlcov/index.html # or xdg-open on Linux
201204** Problem** : Tests pass sometimes, fail other times (flaky tests)
202205
203206** Solution** :
207+
2042081 . Check if tests are properly isolated (no shared state)
2052092 . Verify database cleanup between tests
2062103 . Check for timing issues (use ` freezegun ` for time-based tests)
@@ -210,6 +214,7 @@ open htmlcov/index.html # or xdg-open on Linux
210214** Problem** : Tests take too long to run
211215
212216** Solution** :
217+
2132181 . Run tests in parallel: ` pytest -n auto `
2142192 . Run only unit tests: ` pytest tests/unit/ `
2152203 . Run specific test file instead of entire suite
@@ -240,6 +245,7 @@ open htmlcov/index.html # or xdg-open on Linux
240245## Continuous Integration
241246
242247Tests run automatically on:
248+
243249- Push to ` master ` or ` develop `
244250- Pull requests
245251
0 commit comments