Skip to content

fix: improve mrt init UX — fix db_url quoting bug, clearer prompts and next steps#54

Merged
croc100 merged 2 commits into
mainfrom
fix/mrt-init-ux
Jun 8, 2026
Merged

fix: improve mrt init UX — fix db_url quoting bug, clearer prompts and next steps#54
croc100 merged 2 commits into
mainfrom
fix/mrt-init-ux

Conversation

@croc100

@croc100 croc100 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Problems

Three UX issues with mrt init:

1. db_url quoting bug (silent broken conftest)

When a user typed a literal URL, it was written without quotes:

# BEFORE (broken Python)
db_url=sqlite:///test.db,
# AFTER (correct)
db_url="sqlite:///test.db",

2. Confusing default prompt

The old default value was the raw Python expression os.environ.get("TEST_DATABASE_URL", "sqlite:///test.db") — a first-time user has no idea whether to type a URL or a Python expression.

New default is simply sqlite:///test.db with a tip printed above explaining the env var pattern for CI.

3. Weak next steps

After init completed, users only saw one line. Now shows:

  • Step 1: run dynamic tests with the exact command
  • Step 2: run static analysis with the detected path
  • Docs link for when things go wrong

Bonus: import os is no longer added to generated conftest when a literal URL is used.

Before / After

# BEFORE
Next steps:
  pytest ./test_migrations.py -s

# AFTER
Setup complete. Next steps:

  1. Run dynamic rollback tests (requires a test DB):
     pytest ./test_migrations.py -s

  2. Run static analysis (no DB needed):
     mrt check versions/

  If tests fail, run with -v for details or check docs:
  https://croc100.github.io/pytest-mrt

croc100 added 2 commits June 8, 2026 19:40
- 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
…d 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).
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pytest_mrt/commands/init.py 93.93% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@croc100 croc100 merged commit 30fc010 into main Jun 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants