Commit db4affb
authored
fix: show config errors once at session start instead of per-test (#55)
* docs: update pre-commit section with args example, fix stale v1.3.0 refs
- pre-commit section: add args example for Alembic and Django, note on
pre-commit autoupdate, update rev from v1.3.0 to v1.2.0
- Remove (v1.3.0) version labels from section headers for unreleased features
- Update 'What's new' section to reflect v1.2.0 accurately
Closes #35
* fix: improve mrt init UX — fix db_url quoting bug, clearer prompts and next steps
Three issues fixed:
1. db_url quoting bug: when a user typed a literal URL (e.g. sqlite:///test.db),
it was written as db_url=sqlite:///test.db without quotes — invalid Python.
Now correctly written as db_url="sqlite:///test.db".
2. Confusing default prompt: the old default was the raw Python expression
os.environ.get("TEST_DATABASE_URL", "sqlite:///test.db") which is unclear
for first-time users. Default is now simply sqlite:///test.db with a tip
explaining the env var pattern for CI.
3. Weak next steps: the completion message now shows numbered steps, static
analysis command, and a docs link — so users know exactly what to do next.
Also removes unnecessary 'import os' from generated conftest when a literal
URL is used (os is only imported when the url expr references os.environ).
* fix: show config errors once at session start instead of per-test
Before this change, a missing alembic.ini produced the same error
message for every collected test (typically 7 times), each with a
double traceback due to pytest.fail() being called inside an except
block.
Changes:
- Add pytest_sessionstart hook that validates MRTConfig once and calls
pytest.exit() on fatal config errors -- one clear message, no tests run
- Break exception chain in mrt fixture (capture error string before
calling pytest.fail) to eliminate "During handling of the above
exception" noise
- Simplify MRTConfigError message in MRTFixture.__init__: Django hint
is now only shown via pytest_sessionstart, not duplicated
- Update test assertion to match revised error message text1 parent 30fc010 commit db4affb
2 files changed
Lines changed: 45 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
| |||
301 | 297 | | |
302 | 298 | | |
303 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
304 | 333 | | |
305 | 334 | | |
306 | 335 | | |
| |||
336 | 365 | | |
337 | 366 | | |
338 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
339 | 371 | | |
340 | 372 | | |
341 | 373 | | |
342 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
343 | 378 | | |
344 | 379 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
674 | | - | |
| 674 | + | |
675 | 675 | | |
676 | 676 | | |
677 | 677 | | |
| |||
0 commit comments