Verified Commit f378d41d authored by Petr Špaček's avatar Petr Špaček
Browse files

Deckard: fix mismatch output

Sometimes mismatches values are lists so we have to strigify items
of the list first.
parent 81a0b36e
Pipeline #35059 passed with stage
in 57 seconds
......@@ -3,6 +3,11 @@
import dns.rcode
import dns.edns
from typing import ( # noqa
Any, Sequence, Union)
MismatchValue = Union[str, Sequence[Any]]
class DataMismatch(Exception):
def __init__(self, exp_val, got_val):
......@@ -10,8 +15,17 @@ class DataMismatch(Exception):
self.exp_val = exp_val
self.got_val = got_val
def __str__(self):
return 'expected "{0.exp_val}" got "{0.got_val}"'.format(self)
def format_value(value: MismatchValue) -> str:
if isinstance(value, list):
return ' '.join([str(val) for val in value])
return str(value)
def __str__(self) -> str:
return 'expected "{}" got "{}"'.format(
def __hash__(self):
return hash((self.exp_val, self.got_val))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment