Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from schireson/dc/prettify_error_output
feat: Prettify error output.
- Loading branch information
Showing
6 changed files
with
103 additions
and
20 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
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,34 @@ | ||
import textwrap | ||
|
||
from _pytest._code.code import FormattedExcinfo | ||
|
||
|
||
class AlembicTestFailure(AssertionError): | ||
def __init__(self, message, context=None): | ||
super().__init__(message) | ||
self.context = context | ||
|
||
|
||
class AlembicReprError: | ||
def __init__(self, exce, item): | ||
self.exce = exce | ||
self.item = item | ||
|
||
def toterminal(self, tw): | ||
"""Print out a custom error message to the terminal. | ||
""" | ||
exc = self.exce.value | ||
context = exc.context | ||
|
||
if context: | ||
for title, item in context: | ||
tw.line(title + ":", white=True, bold=True) | ||
tw.line(textwrap.indent(item, " "), red=True) | ||
tw.line("") | ||
|
||
e = FormattedExcinfo() | ||
lines = e.get_exconly(self.exce) | ||
|
||
tw.line("Errors:", white=True, bold=True) | ||
for line in lines: | ||
tw.line(line, red=True, bold=True) |
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