-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/shobrook/rebound
- Loading branch information
Showing
5 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
import traceback | ||
import sys | ||
import os | ||
sys.path.insert(0, os.path.join(os.path.dirname( __file__ ), "..", "rebound")) | ||
import rebound | ||
|
||
# Constants and helper functions | ||
EXCEPTION_DETAILS = "Exception details" | ||
|
||
def gen_python_exception(exception_type): | ||
stack_trace = None | ||
try: | ||
raise exception_type(EXCEPTION_DETAILS) | ||
except Exception: | ||
stack_trace = traceback.format_exc() | ||
return stack_trace | ||
|
||
def gen_expected_message(exception_type_str): | ||
return exception_type_str + ": " + EXCEPTION_DETAILS | ||
|
||
# Tests | ||
@pytest.mark.parametrize("exception_type, exception_type_str", [ | ||
(StopIteration, "StopIteration"), | ||
(StopAsyncIteration, "StopAsyncIteration"), | ||
(ArithmeticError, "ArithmeticError"), | ||
(AssertionError, "AssertionError"), | ||
(AttributeError, "AttributeError"), | ||
(BufferError, "BufferError"), | ||
(EOFError, "EOFError"), | ||
(ImportError, "ImportError"), | ||
(MemoryError, "MemoryError"), | ||
(NameError, "NameError"), | ||
(OSError, "OSError"), | ||
(ReferenceError, "ReferenceError"), | ||
(RuntimeError, "RuntimeError"), | ||
(SyntaxError, "SyntaxError"), | ||
(SystemError, "SystemError"), | ||
(TypeError, "TypeError"), | ||
(ValueError, "ValueError"), | ||
(Warning, "Warning") | ||
]) | ||
def test_get_error_message(exception_type, exception_type_str): | ||
error_message = rebound.get_error_message(gen_python_exception(exception_type), "python3") | ||
expected_error_message = gen_expected_message(exception_type_str) | ||
assert error_message == expected_error_message |