File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
from typing import Optional
2
2
3
3
import attr
4
+ import pytest
4
5
5
6
from fgpyo .util .inspect import attr_from
6
7
from fgpyo .util .inspect import attribute_has_default
@@ -45,3 +46,23 @@ def test_attribute_has_default() -> None:
45
46
assert attribute_has_default (fields_dict ["optional_no_default" ])
46
47
assert attribute_has_default (fields_dict ["optional_with_default_none" ])
47
48
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
+ )
You can’t perform that action at this time.
0 commit comments