Skip to content

Commit

Permalink
change test to use a mock, update changelog & authors
Browse files Browse the repository at this point in the history
  • Loading branch information
saucoide committed Apr 28, 2024
1 parent e5bcd45 commit f797b0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Contributors:
* Hollis Wu (holi0317)
* Antonio Aguilar (crazybolillo)
* Andrew M. MacFie (amacfie)
* saucoide

Creator:
--------
Expand Down
2 changes: 2 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Features:
displaying of all Postgres error fields received.
* Show Postgres notifications.
* Support sqlparse 0.5.x
* Add `--log-file [filename]` cli argument and `\log-file [filename]` special commands to
log to an external file in addition to the normal output

Bug fixes:
----------
Expand Down
8 changes: 5 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,12 @@ def test_logfile_works(executor):
@dbtest
def test_logfile_unwriteable_file(executor):
cli = PGCli(pgexecute=executor)
statement = r"\log-file /etc/forbidden.log"
result = run(executor, statement, pgspecial=cli.pgspecial)
statement = r"\log-file forbidden.log"
with mock.patch("builtins.open") as mock_open:
mock_open.side_effect = PermissionError("[Errno 13] Permission denied: 'forbidden.log'")
result = run(executor, statement, pgspecial=cli.pgspecial)
assert result == [
"[Errno 13] Permission denied: '/etc/forbidden.log'\nLogfile capture disabled"
"[Errno 13] Permission denied: 'forbidden.log'\nLogfile capture disabled"
]


Expand Down

0 comments on commit f797b0b

Please sign in to comment.