diff --git a/AUTHORS b/AUTHORS index 76e44ef1..9f33ff55 100644 --- a/AUTHORS +++ b/AUTHORS @@ -133,6 +133,7 @@ Contributors: * Hollis Wu (holi0317) * Antonio Aguilar (crazybolillo) * Andrew M. MacFie (amacfie) + * saucoide Creator: -------- diff --git a/changelog.rst b/changelog.rst index e09a3251..b915f98e 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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: ---------- diff --git a/tests/test_main.py b/tests/test_main.py index 6b60a41c..4c3949e7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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" ]