-
Notifications
You must be signed in to change notification settings - Fork 13
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 #80 from schireson/dc/manual-vs-automatic-parity
- Loading branch information
Showing
5 changed files
with
33 additions
and
42 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "pytest-alembic" | ||
version = "0.10.1" | ||
version = "0.10.2" | ||
description = "A pytest plugin for verifying alembic migrations." | ||
authors = [ | ||
"Dan Cardin <[email protected]>", | ||
|
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 |
---|---|---|
@@ -1,33 +1,25 @@ | ||
import textwrap | ||
|
||
from _pytest._code.code import FormattedExcinfo | ||
from typing import List | ||
|
||
|
||
class AlembicTestFailure(AssertionError): | ||
def __init__(self, message, context=None): | ||
super().__init__(message) | ||
self.context = context | ||
self.exce = self | ||
self.item = None | ||
|
||
|
||
class AlembicReprError: | ||
def __init__(self, exce, item): | ||
self.exce = exce | ||
self.item = item | ||
|
||
def toterminal(self, tw): | ||
def format_context(self) -> List[str]: | ||
"""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) | ||
result = [] | ||
if not self.context: | ||
return [] | ||
|
||
for title, item in self.context: | ||
result.extend(["", f"{title}:", textwrap.indent(item, " ")]) | ||
return result | ||
|
||
def __str__(self): | ||
content = self.format_context() | ||
segments = [super().__str__(), *content] | ||
return "\n".join(segments) |
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