100% Coverage
This commit is contained in:
parent
9b8e8886bf
commit
70a52d6a13
|
|
@ -158,9 +158,11 @@ class MismatchedContainerError(BootstraparseError):
|
||||||
self.token = token
|
self.token = token
|
||||||
if token:
|
if token:
|
||||||
self.line = token.line_number
|
self.line = token.line_number
|
||||||
|
self.label = token.label
|
||||||
else:
|
else:
|
||||||
self.line = None
|
self.line = None
|
||||||
super().__init__(f"Could not process {token.label} at line {self.line}.")
|
self.label = None
|
||||||
|
super().__init__(f"Could not process {self.label} at line {self.line}.")
|
||||||
|
|
||||||
|
|
||||||
class LonelyOptionalError(BootstraparseError):
|
class LonelyOptionalError(BootstraparseError):
|
||||||
|
|
@ -171,8 +173,10 @@ class LonelyOptionalError(BootstraparseError):
|
||||||
self.token = token
|
self.token = token
|
||||||
if token:
|
if token:
|
||||||
self.line = token.line_number
|
self.line = token.line_number
|
||||||
|
self.label = token.label
|
||||||
else:
|
else:
|
||||||
self.line = None
|
self.line = None
|
||||||
|
self.label = None
|
||||||
if last_in_pile:
|
if last_in_pile:
|
||||||
super().__init__(f"Could not match token {token} at line {self.line} with "
|
super().__init__(f"Could not match token {token} at line {self.line} with "
|
||||||
f"last element in pile {last_in_pile} at line {last_in_pile.line_number} (not a container).")
|
f"last element in pile {last_in_pile} at line {last_in_pile.line_number} (not a container).")
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,7 @@ class ContextConverter:
|
||||||
print(self)
|
print(self)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if hasattr(other, "__str__"):
|
return str(self) == str(other)
|
||||||
return str(self) == str(other)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__': # pragma: no cover
|
if __name__ == '__main__': # pragma: no cover
|
||||||
|
|
|
||||||
|
|
@ -102,5 +102,18 @@ def test_dict_str():
|
||||||
assert error_mngr.str_dict_check({"test": {"test3": "test5"}}, "test", "test3") == "test: True\ntest3: True"
|
assert error_mngr.str_dict_check({"test": {"test3": "test5"}}, "test", "test3") == "test: True\ntest3: True"
|
||||||
|
|
||||||
|
|
||||||
|
def test_weird_exception_cases():
|
||||||
|
with pytest.raises(error_mngr.MismatchedContainerError):
|
||||||
|
raise(error_mngr.MismatchedContainerError(None))
|
||||||
|
|
||||||
|
with pytest.raises(error_mngr.LonelyOptionalError):
|
||||||
|
raise(error_mngr.LonelyOptionalError(None, None))
|
||||||
|
|
||||||
|
from typing import NamedTuple
|
||||||
|
tk = NamedTuple("falsetoken", [("line_number", int), ("label", str)])(1, "test")
|
||||||
|
with pytest.raises(error_mngr.LonelyOptionalError):
|
||||||
|
raise(error_mngr.LonelyOptionalError(tk, None))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
TestLogging().test_init_logging()
|
TestLogging().test_init_logging()
|
||||||
|
|
|
||||||
|
|
@ -172,4 +172,9 @@ def test_context_cov():
|
||||||
convr.readlines()
|
convr.readlines()
|
||||||
convr.__str__()
|
convr.__str__()
|
||||||
convr.print_all()
|
convr.print_all()
|
||||||
_ = convr == convr
|
|
||||||
|
class A:
|
||||||
|
pass
|
||||||
|
|
||||||
|
assert convr == convr
|
||||||
|
assert convr != A()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue