Skip to content

Commit

Permalink
Fix _test database name when using query strings
Browse files Browse the repository at this point in the history
If your DB connection string had 1 or more query strings the test
database name was being appended at the end of the URL instead of
after the database name itself.

Old (broken) behavior:
  myapp?encoding=utf8_test

New (fixed) behavior:
  myapp_test?encoding=utf8
  • Loading branch information
nickjj committed Oct 29, 2022
1 parent e69629b commit 272b35c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -42,6 +42,10 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
- Update `postcss-import` to `15.0.0`
- Update `postcss` to `8.4.17`

### Fixed

- Correctly append `_test` database name to database URI when using query strings

## [0.10.0] - 2022-09-08

### Added
Expand Down
8 changes: 7 additions & 1 deletion test/conftest.py
Expand Up @@ -12,7 +12,13 @@ def app():
:return: Flask app
"""
db_uri = f"{settings.SQLALCHEMY_DATABASE_URI}_test"
db_uri = settings.SQLALCHEMY_DATABASE_URI

if "?" in db_uri:
db_uri = db_uri.replace("?", "_test?")
else:
db_uri = f"{db_uri}_test"

params = {
"DEBUG": False,
"TESTING": True,
Expand Down

0 comments on commit 272b35c

Please sign in to comment.