Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from robotpy/magicbot-inject-init-non-type-msg
magicbot: Fix non-type annotation error for init
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import typing | ||
|
||
import pytest | ||
|
||
from magicbot.inject import get_injection_requests | ||
|
||
|
||
def test_ctor_invalid_type_hint_message(): | ||
""" | ||
class Component: | ||
def __init__(self, foo: 1): ... | ||
""" | ||
type_hints = { | ||
"foo": typing.cast(type, 1), | ||
} | ||
|
||
with pytest.raises(TypeError) as exc_info: | ||
get_injection_requests(type_hints, "bar") | ||
|
||
assert exc_info.value.args[0] == "Component bar has a non-type annotation foo: 1" |