@@ -31,54 +31,88 @@ def test_defaults(self):
31
31
32
32
@pytest .mark .parametrize ('option_name' , boolean_config_options )
33
33
@pytest .mark .parametrize ('value' , [None , 'False' , 1 ])
34
- def test_boolean_config_options_reject_non_bools (self , option_name , value ):
34
+ def test_boolean_config_options_reject_non_bools_init (
35
+ self , option_name , value
36
+ ):
35
37
"""
36
38
The boolean config options raise an error if you try to set a value
37
- that isn't a boolean.
39
+ that isn't a boolean via the initializer .
38
40
"""
39
41
with pytest .raises (ValueError ):
40
- config = h2 .config .H2Configuration (** {option_name : value })
42
+ h2 .config .H2Configuration (** {option_name : value })
41
43
44
+ @pytest .mark .parametrize ('option_name' , boolean_config_options )
45
+ @pytest .mark .parametrize ('value' , [None , 'False' , 1 ])
46
+ def test_boolean_config_options_reject_non_bools_attr (
47
+ self , option_name , value
48
+ ):
49
+ """
50
+ The boolean config options raise an error if you try to set a value
51
+ that isn't a boolean via attribute setter.
52
+ """
42
53
config = h2 .config .H2Configuration ()
43
54
with pytest .raises (ValueError ):
44
55
setattr (config , option_name , value )
45
56
46
57
@pytest .mark .parametrize ('option_name' , boolean_config_options )
47
58
@pytest .mark .parametrize ('value' , [True , False ])
48
- def test_boolean_config_option_is_reflected (self , option_name , value ):
59
+ def test_boolean_config_option_is_reflected_init (self , option_name , value ):
49
60
"""
50
61
The value of the boolean config options, when set, is reflected
51
- in the value.
62
+ in the value via the initializer.
63
+ """
64
+ config = h2 .config .H2Configuration (** {option_name : value })
65
+ assert getattr (config , option_name ) == value
66
+
67
+ @pytest .mark .parametrize ('option_name' , boolean_config_options )
68
+ @pytest .mark .parametrize ('value' , [True , False ])
69
+ def test_boolean_config_option_is_reflected_attr (self , option_name , value ):
70
+ """
71
+ The value of the boolean config options, when set, is reflected
72
+ in the value via attribute setter.
52
73
"""
53
74
config = h2 .config .H2Configuration ()
54
75
setattr (config , option_name , value )
55
76
assert getattr (config , option_name ) == value
56
77
57
- config = h2 .config .H2Configuration (** {option_name : value })
58
- assert getattr (config , option_name ) == value
78
+ @pytest .mark .parametrize ('header_encoding' , [True , 1 , object ()])
79
+ def test_header_encoding_must_be_false_str_none_init (
80
+ self , header_encoding
81
+ ):
82
+ """
83
+ The value of the ``header_encoding`` setting must be False, a string,
84
+ or None via the initializer.
85
+ """
86
+ with pytest .raises (ValueError ):
87
+ h2 .config .H2Configuration (header_encoding = header_encoding )
59
88
60
89
@pytest .mark .parametrize ('header_encoding' , [True , 1 , object ()])
61
- def test_header_encoding_must_be_false_str_none (self , header_encoding ):
90
+ def test_header_encoding_must_be_false_str_none_attr (
91
+ self , header_encoding
92
+ ):
62
93
"""
63
94
The value of the ``header_encoding`` setting must be False, a string,
64
- or None.
95
+ or None via attribute setter .
65
96
"""
66
97
config = h2 .config .H2Configuration ()
67
-
68
98
with pytest .raises (ValueError ):
69
99
config .header_encoding = header_encoding
70
100
71
- with pytest .raises (ValueError ):
72
- config = h2 .config .H2Configuration (header_encoding = header_encoding )
101
+ @pytest .mark .parametrize ('header_encoding' , [False , 'ascii' , None ])
102
+ def test_header_encoding_is_reflected_init (self , header_encoding ):
103
+ """
104
+ The value of ``header_encoding``, when set, is reflected in the value
105
+ via the initializer.
106
+ """
107
+ config = h2 .config .H2Configuration (header_encoding = header_encoding )
108
+ assert config .header_encoding == header_encoding
73
109
74
110
@pytest .mark .parametrize ('header_encoding' , [False , 'ascii' , None ])
75
- def test_header_encoding_is_reflected (self , header_encoding ):
111
+ def test_header_encoding_is_reflected_attr (self , header_encoding ):
76
112
"""
77
- The value of ``header_encoding``, when set, is reflected in the value.
113
+ The value of ``header_encoding``, when set, is reflected in the value
114
+ via the attribute setter.
78
115
"""
79
116
config = h2 .config .H2Configuration ()
80
117
config .header_encoding = header_encoding
81
118
assert config .header_encoding == header_encoding
82
-
83
- config = h2 .config .H2Configuration (header_encoding = header_encoding )
84
- assert config .header_encoding == header_encoding
0 commit comments