Skip to content

Commit 990d303

Browse files
committed
add test
1 parent c1998b7 commit 990d303

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

fgpyo/util/tests/test_inspect.py

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22

33
import attr
4+
import pytest
45

56
from fgpyo.util.inspect import attr_from
67
from fgpyo.util.inspect import attribute_has_default
@@ -45,3 +46,23 @@ def test_attribute_has_default() -> None:
4546
assert attribute_has_default(fields_dict["optional_no_default"])
4647
assert attribute_has_default(fields_dict["optional_with_default_none"])
4748
assert attribute_has_default(fields_dict["optional_with_default_some"])
49+
50+
51+
class Foo:
52+
pass
53+
54+
55+
@attr.s(auto_attribs=True, frozen=True)
56+
class Bar:
57+
foo: Foo
58+
59+
60+
# Test for regression #94 - the call to attr_from succeeds when the check for None type
61+
# in inspect._get_parser is done incorrectly.
62+
def test_attr_from_custom_type_without_parser_fails() -> None:
63+
with pytest.raises(AssertionError):
64+
attr_from(
65+
cls=Bar,
66+
kwargs={"foo": ""},
67+
parsers={},
68+
)

0 commit comments

Comments
 (0)