Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions with non str args #2

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "unittest-extensions"
version = "0.2.4"
version = "0.2.5"
authors = [
{ name="Maximos Nikiforakis", email="[email protected]" },
]
Expand Down
3 changes: 2 additions & 1 deletion src/unittest_extensions/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def result(self) -> Any:
except Exception as e:
if len(e.args) == 0:
raise e
msg = e.args[0]

msg = str(e.args[0])
if "subject() got an unexpected keyword argument" in msg:
raise TestError(
"Subject received "
Expand Down
9 changes: 8 additions & 1 deletion src/unittest_extensions/tests/test_use_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def test_raises_test_error(self):


class TestAppend(TestCase):

def instance(self) -> TestClass:
return TestClass()

Expand Down Expand Up @@ -204,3 +203,11 @@ def subject(self):

def test_reraises_empty_exception(self):
self.assertResultRaises(self.MyError)


class TestRaiseExceptionWithNonStrArgs(TestCase):
def subject(self):
raise KeyError(2)

def test_reraises_error(self):
self.assertResultRaises(KeyError)
Loading