-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "fix alembic.util.messaging.msg to properly wrap at terminal wi…
…dth" into main
- Loading branch information
Showing
4 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. change:: | ||
:tags: bug, commands | ||
:tickets: 1384 | ||
|
||
Fixed bug in alembic command stdout where long messages were not properly | ||
wrapping at the terminal width. Pull request courtesy Saif Hakim. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from io import StringIO | ||
|
||
from alembic.testing import eq_ | ||
from alembic.testing import mock | ||
from alembic.testing.fixtures import TestBase | ||
from alembic.util.messaging import msg | ||
from alembic.util.messaging import obfuscate_url_pw | ||
|
||
|
||
class MessagingTest(TestBase): | ||
def test_msg_wraps(self): | ||
buf = StringIO() | ||
with mock.patch("sys.stdout", buf), mock.patch( | ||
"alembic.util.messaging.TERMWIDTH", 10 | ||
): | ||
msg("AAAAAAAAAAAAAAAAA") | ||
eq_( | ||
str(buf.getvalue()).splitlines(), | ||
[ | ||
" AAAAAAAA", # initial indent 10 chars before wrapping | ||
" AAAAAAAA", # subsequent indent 10 chars before wrapping | ||
" A", # subsequent indent with remainining chars | ||
], | ||
) | ||
|
||
def test_current_obfuscate_password(self): | ||
eq_( | ||
obfuscate_url_pw("postgresql://scott:tiger@localhost/test"), | ||
"postgresql://scott:***@localhost/test", | ||
) |