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

Cleanup TestError #2177

Merged
merged 8 commits into from Nov 8, 2020
Merged

Cleanup TestError #2177

merged 8 commits into from Nov 8, 2020

Conversation

ktbarrett
Copy link
Member

@ktbarrett ktbarrett commented Nov 5, 2020

TestError was unnecessary here. It was used to fail the test if a signal could not be mapped to a Python SimHandle type. This could be easily done with a standard exception. This cleans up the last usage of TestError in core code and will allow for it's deprecation.

Closes #2174.

…o a Python type

`TestError` was unnecessary here. It was used to fail the test if a signal could not be mapped to a Python SimHandle type. This could be easily done with a standard exception. This cleans up the last usage of `TestError` in core code and will allow for it's deprecation.
@ktbarrett ktbarrett added the type:cleanup cleanup or refactoring on code, documentation, or other areas label Nov 5, 2020
TestError is no longer used internally, and it was never a good idea for a user to raise a TestError rather than a TestFailure, so it is being deprecated.
cocotb/result.py Outdated Show resolved Hide resolved
cocotb/result.py Outdated Show resolved Hide resolved
cocotb/handle.py Outdated Show resolved Hide resolved
`assert_raises` causes 2 warnings. One for calling into the deprecated `assert_raises` and another for instantiating the deprecated `TestError`.
cocotb/handle.py Outdated Show resolved Hide resolved
@ktbarrett
Copy link
Member Author

ktbarrett commented Nov 5, 2020

Instead of creating 2 warnings I could remove the warning from create_error and raise_error and let only the one in TestError be reported.

Decided against this, the stacklevel and message would be off.

cocotb/handle.py Outdated Show resolved Hide resolved
cocotb/handle.py Outdated Show resolved Hide resolved
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
cocotb/handle.py Outdated Show resolved Hide resolved
cocotb/result.py Outdated Show resolved Hide resolved
@cmarqu cmarqu added the status:needs-newsfragment Needs a towncrier newsfragment for the changelog label Nov 5, 2020
@cmarqu
Copy link
Contributor

cmarqu commented Nov 5, 2020

Should have a 2177.removal.rst newsfragment and a "Closes #2174." in the commit message.

ktbarrett and others added 2 commits November 6, 2020 17:27
Co-authored-by: Marlon James <marlon.james@garmin.com>
@ktbarrett ktbarrett requested a review from cmarqu November 8, 2020 18:49
@ktbarrett ktbarrett removed the status:needs-newsfragment Needs a towncrier newsfragment for the changelog label Nov 8, 2020
@ktbarrett ktbarrett merged commit 93e5a46 into master Nov 8, 2020
@ktbarrett ktbarrett deleted the test-error-cleanup branch November 8, 2020 22:49
cmarqu pushed a commit to cmarqu/cocotb that referenced this pull request Nov 17, 2020
* Use a more appropriate exception when a GPI object cannot be mapped to a Python type

`TestError` was unnecessary here. It was used to fail the test if a signal could not be mapped to a Python SimHandle type. This could be easily done with a standard exception. This cleans up the last usage of `TestError` in core code and will allow for it's deprecation.

* Deprecate TestError

TestError is no longer used internally, and it was never a good idea for a user to raise a TestError rather than a TestFailure, so it is being deprecated.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Marlon James <marlon.james@garmin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:cleanup cleanup or refactoring on code, documentation, or other areas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate TestError/expect_error
4 participants