raisefunction 1.0.3__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {raisefunction-1.0.3/src/raisefunction.egg-info → raisefunction-1.0.5}/PKG-INFO +1 -2
- {raisefunction-1.0.3 → raisefunction-1.0.5}/pyproject.toml +3 -5
- raisefunction-1.0.5/src/raisefunction/__init__.py +2 -0
- raisefunction-1.0.5/src/raisefunction/core/__init__.py +27 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/src/raisefunction/tests/__init__.py +4 -0
- raisefunction-1.0.5/src/raisefunction/tests/test_0.py +51 -0
- raisefunction-1.0.5/src/raisefunction/tests/test_1.py +62 -0
- raisefunction-1.0.5/src/raisefunction/tests/test_2.py +76 -0
- raisefunction-1.0.5/src/raisefunction/tests/test_3.py +42 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5/src/raisefunction.egg-info}/PKG-INFO +1 -2
- {raisefunction-1.0.3 → raisefunction-1.0.5}/src/raisefunction.egg-info/SOURCES.txt +3 -2
- raisefunction-1.0.3/src/raisefunction/__init__.py +0 -5
- raisefunction-1.0.3/src/raisefunction/core/__init__.py +0 -29
- raisefunction-1.0.3/src/raisefunction/tests/test_0.py +0 -41
- raisefunction-1.0.3/src/raisefunction/tests/test_1.py +0 -17
- raisefunction-1.0.3/src/raisefunction.egg-info/requires.txt +0 -1
- {raisefunction-1.0.3 → raisefunction-1.0.5}/LICENSE.txt +0 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/MANIFEST.in +0 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/README.rst +0 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/setup.cfg +0 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/src/raisefunction.egg-info/dependency_links.txt +0 -0
- {raisefunction-1.0.3 → raisefunction-1.0.5}/src/raisefunction.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: raisefunction
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: This project provides a function that raises errors passed to it.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -40,7 +40,6 @@ Classifier: Typing :: Typed
|
|
|
40
40
|
Requires-Python: >=3.11
|
|
41
41
|
Description-Content-Type: text/x-rst
|
|
42
42
|
License-File: LICENSE.txt
|
|
43
|
-
Requires-Dist: overloadable<2,>=1.0.14
|
|
44
43
|
Dynamic: license-file
|
|
45
44
|
|
|
46
45
|
=============
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
3
|
requires = [
|
|
4
|
-
"setuptools>=
|
|
4
|
+
"setuptools>=64.0",
|
|
5
5
|
]
|
|
6
6
|
|
|
7
7
|
[project]
|
|
@@ -19,15 +19,13 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: 3 :: Only",
|
|
20
20
|
"Typing :: Typed",
|
|
21
21
|
]
|
|
22
|
-
dependencies = [
|
|
23
|
-
"overloadable>=1.0.14,<2",
|
|
24
|
-
]
|
|
22
|
+
dependencies = []
|
|
25
23
|
description = "This project provides a function that raises errors passed to it."
|
|
26
24
|
keywords = []
|
|
27
25
|
name = "raisefunction"
|
|
28
26
|
readme = "README.rst"
|
|
29
27
|
requires-python = ">=3.11"
|
|
30
|
-
version = "1.0.
|
|
28
|
+
version = "1.0.5"
|
|
31
29
|
|
|
32
30
|
[project.license]
|
|
33
31
|
file = "LICENSE.txt"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import *
|
|
2
|
+
|
|
3
|
+
__all__ = ["raisefunction"]
|
|
4
|
+
|
|
5
|
+
DEFAULT = object()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@overload
|
|
9
|
+
def raisefunction(
|
|
10
|
+
exc: BaseException | type[BaseException],
|
|
11
|
+
) -> Never: ...
|
|
12
|
+
@overload
|
|
13
|
+
def raisefunction(
|
|
14
|
+
exc: BaseException | type[BaseException],
|
|
15
|
+
cause: Optional[BaseException],
|
|
16
|
+
) -> Never: ...
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def raisefunction(
|
|
20
|
+
exc: BaseException | type[BaseException],
|
|
21
|
+
cause: Optional[BaseException] | object = DEFAULT,
|
|
22
|
+
) -> Never:
|
|
23
|
+
"This function raises the given exception."
|
|
24
|
+
if cause is DEFAULT:
|
|
25
|
+
raise exc
|
|
26
|
+
else:
|
|
27
|
+
raise exc from cause
|
|
@@ -5,6 +5,10 @@ __all__ = ["test"]
|
|
|
5
5
|
|
|
6
6
|
def test() -> unittest.TextTestRunner:
|
|
7
7
|
"This function runs all the tests."
|
|
8
|
+
loader: unittest.TestLoader
|
|
9
|
+
tests: unittest.TestSuite
|
|
10
|
+
runner: unittest.TextTestRunner
|
|
11
|
+
result: unittest.TextTestResult
|
|
8
12
|
loader = unittest.TestLoader()
|
|
9
13
|
tests = loader.discover(start_dir="raisefunction.tests")
|
|
10
14
|
runner = unittest.TextTestRunner()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
from raisefunction.core import raisefunction
|
|
5
|
+
|
|
6
|
+
__all__ = ["Test0"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Test0(unittest.TestCase):
|
|
10
|
+
def test_dispatcher_no_arguments(self: Self) -> None:
|
|
11
|
+
"Test the dispatcher raises a TypeError with no arguments."
|
|
12
|
+
with self.assertRaises(TypeError):
|
|
13
|
+
raisefunction()
|
|
14
|
+
# self.assertIn("requires at least 1 positional argument", str(context.exception))
|
|
15
|
+
|
|
16
|
+
def test_dispatcher_too_many_arguments(self: Self) -> None:
|
|
17
|
+
"Test the dispatcher raises a TypeError with more than 2 arguments."
|
|
18
|
+
with self.assertRaises(TypeError):
|
|
19
|
+
raisefunction(1, 2, 3)
|
|
20
|
+
# self.assertIn("takes at most 2 positional arguments", str(context.exception))
|
|
21
|
+
|
|
22
|
+
def test_raise_single_exception(self: Self) -> None:
|
|
23
|
+
"Test the single exception raising overload."
|
|
24
|
+
with self.assertRaises(ValueError):
|
|
25
|
+
raisefunction(ValueError("Test single exception"))
|
|
26
|
+
|
|
27
|
+
def test_raise_exception_with_cause(self: Self) -> None:
|
|
28
|
+
"Test the exception raising overload with a cause."
|
|
29
|
+
with self.assertRaises(ValueError) as context:
|
|
30
|
+
raisefunction(ValueError("Test exception"), TypeError("Cause exception"))
|
|
31
|
+
self.assertEqual(str(context.exception), "Test exception")
|
|
32
|
+
self.assertIsInstance(context.exception.__cause__, TypeError)
|
|
33
|
+
self.assertEqual(str(context.exception.__cause__), "Cause exception")
|
|
34
|
+
|
|
35
|
+
def test_invalid_arguments_in_overloads(self: Self) -> None:
|
|
36
|
+
"Test invalid argument types raise appropriate errors."
|
|
37
|
+
with self.assertRaises(TypeError):
|
|
38
|
+
raisefunction("not an exception")
|
|
39
|
+
with self.assertRaises(TypeError):
|
|
40
|
+
raisefunction("not an exception", "not a cause")
|
|
41
|
+
|
|
42
|
+
def test_raise_exception_with_cause(self: Self) -> None:
|
|
43
|
+
"Test the exception raising overload with a cause."
|
|
44
|
+
with self.assertRaises(ValueError) as context:
|
|
45
|
+
raisefunction(ValueError("Test exception"), KeyError("Cause exception"))
|
|
46
|
+
self.assertEqual(str(context.exception), "Test exception")
|
|
47
|
+
self.assertIsInstance(context.exception.__cause__, KeyError)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
unittest.main()
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
from raisefunction import core
|
|
5
|
+
|
|
6
|
+
__all__ = ["Test1"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Test1(unittest.TestCase):
|
|
10
|
+
def test_raises_given_exception_instance_without_cause(self: Self) -> None:
|
|
11
|
+
exc: ValueError
|
|
12
|
+
exc = ValueError("boom")
|
|
13
|
+
|
|
14
|
+
with self.assertRaises(ValueError) as cm:
|
|
15
|
+
core.raisefunction(exc)
|
|
16
|
+
|
|
17
|
+
self.assertIs(cm.exception, exc)
|
|
18
|
+
# When no explicit cause is given, __cause__ is normally None
|
|
19
|
+
# and __context__ may or may not be set depending on context.
|
|
20
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
21
|
+
|
|
22
|
+
def test_raises_given_exception_class_without_cause(self: Self) -> None:
|
|
23
|
+
# Using a class mirrors: raise ValueError
|
|
24
|
+
with self.assertRaises(ValueError) as cm:
|
|
25
|
+
core.raisefunction(ValueError)
|
|
26
|
+
self.assertIsInstance(cm.exception, ValueError)
|
|
27
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
28
|
+
|
|
29
|
+
def test_raises_with_explicit_cause(self: Self) -> None:
|
|
30
|
+
cause: RuntimeError
|
|
31
|
+
exc: ValueError
|
|
32
|
+
cause = RuntimeError("original")
|
|
33
|
+
exc = ValueError("wrapped")
|
|
34
|
+
|
|
35
|
+
with self.assertRaises(ValueError) as cm:
|
|
36
|
+
core.raisefunction(exc, cause)
|
|
37
|
+
|
|
38
|
+
self.assertIs(cm.exception.__cause__, cause)
|
|
39
|
+
|
|
40
|
+
def test_raises_with_suppressed_context_when_cause_is_none(self: Self) -> None:
|
|
41
|
+
exc: ValueError
|
|
42
|
+
exc = ValueError("no context")
|
|
43
|
+
|
|
44
|
+
# Explicit `from None` should result in __cause__ being None,
|
|
45
|
+
# and suppress linking to any active exception.
|
|
46
|
+
with self.assertRaises(ValueError) as cm:
|
|
47
|
+
core.raisefunction(exc, None)
|
|
48
|
+
|
|
49
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
50
|
+
|
|
51
|
+
def test_raising_class_that_requires_args_produces_type_error(self: Self) -> None:
|
|
52
|
+
class NeedsArg(Exception):
|
|
53
|
+
def __init__(self: Self, msg: str) -> None:
|
|
54
|
+
super().__init__(msg)
|
|
55
|
+
|
|
56
|
+
# This mirrors normal `raise NeedsArg` behaviour
|
|
57
|
+
with self.assertRaises(TypeError):
|
|
58
|
+
core.raisefunction(NeedsArg)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
unittest.main()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
from raisefunction import core
|
|
5
|
+
|
|
6
|
+
__all__ = ["Test2"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Test2(unittest.TestCase):
|
|
10
|
+
def test_raises_given_exception_instance_without_cause(self: Self) -> None:
|
|
11
|
+
cm: unittest._AssertRaisesContext[ValueError]
|
|
12
|
+
exc: ValueError
|
|
13
|
+
exc = ValueError("boom")
|
|
14
|
+
|
|
15
|
+
with self.assertRaises(ValueError) as cm:
|
|
16
|
+
core.raisefunction(exc)
|
|
17
|
+
|
|
18
|
+
self.assertIs(cm.exception, exc)
|
|
19
|
+
# When no explicit cause is given, __cause__ is normally None.
|
|
20
|
+
# __context__ may or may not be set depending on context.
|
|
21
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
22
|
+
|
|
23
|
+
def test_raises_given_exception_class_without_cause(self: Self) -> None:
|
|
24
|
+
cm: unittest._AssertRaisesContext[ValueError]
|
|
25
|
+
with self.assertRaises(ValueError) as cm:
|
|
26
|
+
core.raisefunction(ValueError)
|
|
27
|
+
|
|
28
|
+
self.assertIsInstance(cm.exception, ValueError)
|
|
29
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
30
|
+
|
|
31
|
+
def test_raises_with_explicit_cause(self: Self) -> None:
|
|
32
|
+
cause: RuntimeError
|
|
33
|
+
cm: unittest._AssertRaisesContext[ValueError]
|
|
34
|
+
exc: ValueError
|
|
35
|
+
cause = RuntimeError("original")
|
|
36
|
+
exc = ValueError("wrapped")
|
|
37
|
+
|
|
38
|
+
with self.assertRaises(ValueError) as cm:
|
|
39
|
+
core.raisefunction(exc, cause)
|
|
40
|
+
|
|
41
|
+
self.assertIs(cm.exception.__cause__, cause)
|
|
42
|
+
|
|
43
|
+
def test_raise_from_None(self: Self) -> None:
|
|
44
|
+
cm: unittest._AssertRaisesContext[ValueError]
|
|
45
|
+
exc: ValueError
|
|
46
|
+
one: int
|
|
47
|
+
zero: int
|
|
48
|
+
|
|
49
|
+
exc = ValueError("no context")
|
|
50
|
+
with self.assertRaises(ValueError) as cm:
|
|
51
|
+
try:
|
|
52
|
+
# Create a real context exception
|
|
53
|
+
one = 1
|
|
54
|
+
zero = 0
|
|
55
|
+
one / zero
|
|
56
|
+
except ZeroDivisionError:
|
|
57
|
+
raise exc from None
|
|
58
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
59
|
+
self.assertIsInstance(cm.exception.__context__, ZeroDivisionError)
|
|
60
|
+
self.assertTrue(cm.exception.__suppress_context__)
|
|
61
|
+
|
|
62
|
+
def test_raising_class_that_requires_args_produces_type_error(self: Self) -> None:
|
|
63
|
+
class NeedsArg(Exception):
|
|
64
|
+
def __init__(self: Self, msg: str) -> None:
|
|
65
|
+
super().__init__(msg)
|
|
66
|
+
|
|
67
|
+
cm: unittest._AssertRaisesContext[BaseException]
|
|
68
|
+
with self.assertRaises(TypeError) as cm:
|
|
69
|
+
core.raisefunction(NeedsArg)
|
|
70
|
+
|
|
71
|
+
# Optional: sanity check on the error type/message
|
|
72
|
+
self.assertIsInstance(cm.exception, TypeError)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
unittest.main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
from raisefunction import core
|
|
5
|
+
|
|
6
|
+
__all__ = ["Test3"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Test3(unittest.TestCase):
|
|
10
|
+
|
|
11
|
+
def go(self: Self, *, use_func: bool) -> None:
|
|
12
|
+
cm: unittest._AssertRaisesContext[ValueError]
|
|
13
|
+
exc: ValueError
|
|
14
|
+
exc = ValueError("no context")
|
|
15
|
+
with self.assertRaises(ValueError) as cm:
|
|
16
|
+
self.go_with(use_func=use_func, exc=exc)
|
|
17
|
+
self.assertIsNone(cm.exception.__cause__)
|
|
18
|
+
self.assertIsInstance(cm.exception.__context__, ZeroDivisionError)
|
|
19
|
+
self.assertTrue(cm.exception.__suppress_context__)
|
|
20
|
+
|
|
21
|
+
def go_with(self: Self, *, use_func: bool, exc: Exception) -> None:
|
|
22
|
+
one: int
|
|
23
|
+
zero: int
|
|
24
|
+
try:
|
|
25
|
+
# Create a real context exception
|
|
26
|
+
one = 1
|
|
27
|
+
zero = 0
|
|
28
|
+
one / zero
|
|
29
|
+
except ZeroDivisionError:
|
|
30
|
+
# This should behave like: raise exc from None
|
|
31
|
+
if use_func:
|
|
32
|
+
core.raisefunction(exc, None)
|
|
33
|
+
else:
|
|
34
|
+
raise exc from None
|
|
35
|
+
|
|
36
|
+
def test_raise_from_None(self: Self) -> None:
|
|
37
|
+
self.go(use_func=False)
|
|
38
|
+
self.go(use_func=True)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
unittest.main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: raisefunction
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: This project provides a function that raises errors passed to it.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -40,7 +40,6 @@ Classifier: Typing :: Typed
|
|
|
40
40
|
Requires-Python: >=3.11
|
|
41
41
|
Description-Content-Type: text/x-rst
|
|
42
42
|
License-File: LICENSE.txt
|
|
43
|
-
Requires-Dist: overloadable<2,>=1.0.14
|
|
44
43
|
Dynamic: license-file
|
|
45
44
|
|
|
46
45
|
=============
|
|
@@ -7,9 +7,10 @@ src/raisefunction/__init__.py
|
|
|
7
7
|
src/raisefunction.egg-info/PKG-INFO
|
|
8
8
|
src/raisefunction.egg-info/SOURCES.txt
|
|
9
9
|
src/raisefunction.egg-info/dependency_links.txt
|
|
10
|
-
src/raisefunction.egg-info/requires.txt
|
|
11
10
|
src/raisefunction.egg-info/top_level.txt
|
|
12
11
|
src/raisefunction/core/__init__.py
|
|
13
12
|
src/raisefunction/tests/__init__.py
|
|
14
13
|
src/raisefunction/tests/test_0.py
|
|
15
|
-
src/raisefunction/tests/test_1.py
|
|
14
|
+
src/raisefunction/tests/test_1.py
|
|
15
|
+
src/raisefunction/tests/test_2.py
|
|
16
|
+
src/raisefunction/tests/test_3.py
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from typing import *
|
|
2
|
-
|
|
3
|
-
from overloadable import overloadable
|
|
4
|
-
|
|
5
|
-
__all__ = ["raisefunction"]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@overloadable
|
|
9
|
-
def raisefunction(*args: Any, **kwargs: Any) -> int:
|
|
10
|
-
"This function works as dispatcher."
|
|
11
|
-
argc: int = len(args)
|
|
12
|
-
keys: set = set(kwargs.keys())
|
|
13
|
-
if argc <= 1 and keys == set():
|
|
14
|
-
return 1
|
|
15
|
-
if argc == 0 and keys == {"exc"}:
|
|
16
|
-
return 1
|
|
17
|
-
return 2
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@raisefunction.overload(1)
|
|
21
|
-
def raisefunction(exc: BaseException) -> None:
|
|
22
|
-
"This function raises the given exception."
|
|
23
|
-
raise exc
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@raisefunction.overload(2)
|
|
27
|
-
def raisefunction(exc: BaseException, cause: Optional[BaseException]) -> None:
|
|
28
|
-
"This function raises the given exception with the given cause."
|
|
29
|
-
raise exc from cause
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
|
|
3
|
-
from raisefunction.core import raisefunction
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TestRaiseFunction(unittest.TestCase):
|
|
7
|
-
def test_dispatcher_no_arguments(self):
|
|
8
|
-
"""Test the dispatcher raises a TypeError with no arguments."""
|
|
9
|
-
with self.assertRaises(TypeError) as context:
|
|
10
|
-
raisefunction()
|
|
11
|
-
# self.assertIn("requires at least 1 positional argument", str(context.exception))
|
|
12
|
-
|
|
13
|
-
def test_dispatcher_too_many_arguments(self):
|
|
14
|
-
"""Test the dispatcher raises a TypeError with more than 2 arguments."""
|
|
15
|
-
with self.assertRaises(TypeError) as context:
|
|
16
|
-
raisefunction(1, 2, 3)
|
|
17
|
-
# self.assertIn("takes at most 2 positional arguments", str(context.exception))
|
|
18
|
-
|
|
19
|
-
def test_raise_single_exception(self):
|
|
20
|
-
"""Test the single exception raising overload."""
|
|
21
|
-
with self.assertRaises(ValueError):
|
|
22
|
-
raisefunction(ValueError("Test single exception"))
|
|
23
|
-
|
|
24
|
-
def test_raise_exception_with_cause(self):
|
|
25
|
-
"""Test the exception raising overload with a cause."""
|
|
26
|
-
with self.assertRaises(ValueError) as context:
|
|
27
|
-
raisefunction(ValueError("Test exception"), TypeError("Cause exception"))
|
|
28
|
-
self.assertEqual(str(context.exception), "Test exception")
|
|
29
|
-
self.assertIsInstance(context.exception.__cause__, TypeError)
|
|
30
|
-
self.assertEqual(str(context.exception.__cause__), "Cause exception")
|
|
31
|
-
|
|
32
|
-
def test_invalid_arguments_in_overloads(self):
|
|
33
|
-
"""Test invalid argument types raise appropriate errors."""
|
|
34
|
-
with self.assertRaises(TypeError):
|
|
35
|
-
raisefunction("not an exception")
|
|
36
|
-
with self.assertRaises(TypeError):
|
|
37
|
-
raisefunction("not an exception", "not a cause")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if __name__ == "__main__":
|
|
41
|
-
unittest.main()
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
|
|
3
|
-
from raisefunction.core import raisefunction
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TestRaiseFunction(unittest.TestCase):
|
|
7
|
-
|
|
8
|
-
def test_raise_exception_with_cause(self):
|
|
9
|
-
"""Test the exception raising overload with a cause."""
|
|
10
|
-
with self.assertRaises(ValueError) as context:
|
|
11
|
-
raisefunction(ValueError("Test exception"), KeyError("Cause exception"))
|
|
12
|
-
self.assertEqual(str(context.exception), "Test exception")
|
|
13
|
-
self.assertIsInstance(context.exception.__cause__, KeyError)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if __name__ == "__main__":
|
|
17
|
-
unittest.main()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
overloadable<2,>=1.0.14
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|