-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement __format__ for a more fine grained output of the error (#50)
--------- Co-authored-by: Nicola Coretti <[email protected]>
- Loading branch information
1 parent
babe4a2
commit 9a7ceb0
Showing
4 changed files
with
177 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ | |
|
||
* Relocked Dependencies | ||
* Update toolbox workflows | ||
|
||
## Added | ||
|
||
* Added support for finegrained error output control |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,131 @@ | ||
import pytest | ||
|
||
from exasol.error._error import Error | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"error, fmt, expected", | ||
[ | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"", | ||
"", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"unknown", | ||
"", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"long", | ||
"E-TEST-1 ['Not enough space on device {/dev/sda1}.'] ['Delete something from {/dev/sda1}', 'Create larger partition.'] {'device': '/dev/sda1'}", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"short", | ||
"E-TEST-1 ['Not enough space on device {/dev/sda1}.']", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"name", | ||
"E-TEST-1", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"message", | ||
"['Not enough space on device {/dev/sda1}.']", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"mitigations", | ||
"['Delete something from {/dev/sda1}', 'Create larger partition.']", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"parameters", | ||
"{'device': '/dev/sda1'}", | ||
), | ||
( | ||
Error( | ||
code="E-TEST-1", | ||
message="Not enough space on device {/dev/sda1}.", | ||
mitigations=[ | ||
"Delete something from {/dev/sda1}", | ||
"Create larger partition.", | ||
], | ||
parameters={"device": "/dev/sda1"}, | ||
), | ||
"parameters mitigations message name", | ||
"{'device': '/dev/sda1'} ['Delete something from {/dev/sda1}', 'Create larger partition.'] ['Not enough space on device {/dev/sda1}.'] E-TEST-1", | ||
), | ||
], | ||
) | ||
def test_fmt(error, fmt, expected): | ||
fmt_str = f"{{error:{fmt}}}" | ||
actual = fmt_str.format(error=error) | ||
assert actual == expected |