6
6
7
7
import pytest
8
8
9
- from attr ._make import attributes , attr
9
+ from attr ._make import attributes , attr , fields
10
10
from attr .filters import _split_what , include , exclude
11
- from attr ._funcs import by_name
12
11
13
12
14
13
@attributes
@@ -38,28 +37,28 @@ class TestInclude(object):
38
37
@pytest .mark .parametrize ("incl,value" , [
39
38
((int ,), 42 ),
40
39
((str ,), "hello" ),
41
- ((str , by_name ( C , "a" ) ), 42 ),
42
- ((str , by_name ( C , "b" ) ), "hello" ),
40
+ ((str , fields ( C ). a ), 42 ),
41
+ ((str , fields ( C ). b ), "hello" ),
43
42
])
44
43
def test_allow (self , incl , value ):
45
44
"""
46
45
Return True if a class or attribute is whitelisted.
47
46
"""
48
47
i = include (* incl )
49
- assert i (by_name ( C , "a" ) , value ) is True
48
+ assert i (fields ( C ). a , value ) is True
50
49
51
50
@pytest .mark .parametrize ("incl,value" , [
52
51
((str ,), 42 ),
53
52
((int ,), "hello" ),
54
- ((str , by_name ( C , "b" ) ), 42 ),
55
- ((int , by_name ( C , "b" ) ), "hello" ),
53
+ ((str , fields ( C ). b ), 42 ),
54
+ ((int , fields ( C ). b ), "hello" ),
56
55
])
57
56
def test_drop_class (self , incl , value ):
58
57
"""
59
58
Return False on non-whitelisted classes and attributes.
60
59
"""
61
60
i = include (* incl )
62
- assert i (by_name ( C , "a" ) , value ) is False
61
+ assert i (fields ( C ). a , value ) is False
63
62
64
63
65
64
class TestExclude (object ):
@@ -69,25 +68,25 @@ class TestExclude(object):
69
68
@pytest .mark .parametrize ("excl,value" , [
70
69
((str ,), 42 ),
71
70
((int ,), "hello" ),
72
- ((str , by_name ( C , "b" ) ), 42 ),
73
- ((int , by_name ( C , "b" ) ), "hello" ),
71
+ ((str , fields ( C ). b ), 42 ),
72
+ ((int , fields ( C ). b ), "hello" ),
74
73
])
75
74
def test_allow (self , excl , value ):
76
75
"""
77
76
Return True if class or attribute is not blacklisted.
78
77
"""
79
78
e = exclude (* excl )
80
- assert e (by_name ( C , "a" ) , value ) is True
79
+ assert e (fields ( C ). a , value ) is True
81
80
82
81
@pytest .mark .parametrize ("excl,value" , [
83
82
((int ,), 42 ),
84
83
((str ,), "hello" ),
85
- ((str , by_name ( C , "a" ) ), 42 ),
86
- ((str , by_name ( C , "b" ) ), "hello" ),
84
+ ((str , fields ( C ). a ), 42 ),
85
+ ((str , fields ( C ). b ), "hello" ),
87
86
])
88
87
def test_drop_class (self , excl , value ):
89
88
"""
90
89
Return True on non-blacklisted classes and attributes.
91
90
"""
92
91
e = exclude (* excl )
93
- assert e (by_name ( C , "a" ) , value ) is False
92
+ assert e (fields ( C ). a , value ) is False
0 commit comments