Skip to content

Commit

Permalink
rename exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Feb 15, 2023
1 parent d8d54b5 commit a992a00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions web_poet/testing/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ class FieldMissing(AssertionError):
pass


class FieldValueError(AssertionError):
class FieldValueIncorrect(AssertionError):
pass


class ItemValueError(AssertionError):
class FieldsUnexpected(AssertionError):
pass


class FieldsUnexpected(AssertionError):
class ItemValueIncorrect(AssertionError):
pass
11 changes: 8 additions & 3 deletions web_poet/testing/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
)
from web_poet.utils import ensure_awaitable, memoizemethod_noargs

from .exceptions import FieldMissing, FieldsUnexpected, FieldValueError, ItemValueError
from .exceptions import (
FieldMissing,
FieldsUnexpected,
FieldValueIncorrect,
ItemValueIncorrect,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -164,7 +169,7 @@ def assert_full_item_correct(self):
output = self.get_output()
expected_output = self.get_expected_output()
if output != expected_output:
raise ItemValueError(output, expected_output)
raise ItemValueIncorrect(output, expected_output)

def assert_field_correct(self, name: str):
"""Assert that a certain field in the output matches the expected value"""
Expand All @@ -173,7 +178,7 @@ def assert_field_correct(self, name: str):
raise FieldMissing(name)
output = self.get_output()[name]
if output != expected_output:
raise FieldValueError(output, expected_output)
raise FieldValueIncorrect(output, expected_output)

def assert_no_extra_fields(self):
"""Assert that there are no extra fields in the output"""
Expand Down
8 changes: 4 additions & 4 deletions web_poet/testing/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from web_poet.testing.exceptions import (
FieldMissing,
FieldsUnexpected,
FieldValueError,
ItemValueError,
FieldValueIncorrect,
ItemValueIncorrect,
)
from web_poet.testing.fixture import OUTPUT_FILE_NAME, Fixture
from web_poet.testing.utils import comparison_error_message
Expand Down Expand Up @@ -90,7 +90,7 @@ def reportinfo(self):
return self._path, 0, f"{self.fixture.short_name}"

def repr_failure(self, excinfo, style=None):
if isinstance(excinfo.value, ItemValueError):
if isinstance(excinfo.value, ItemValueIncorrect):
got, expected = excinfo.value.args
return comparison_error_message(
config=self.config,
Expand Down Expand Up @@ -136,7 +136,7 @@ def reportinfo(self):
return self._path, 0, f"{self.fixture.short_name} @ {self.field_name}"

def repr_failure(self, excinfo, style=None):
if isinstance(excinfo.value, FieldValueError):
if isinstance(excinfo.value, FieldValueIncorrect):
got, expected = excinfo.value.args
return comparison_error_message(
config=self.config,
Expand Down

0 comments on commit a992a00

Please sign in to comment.