@@ -31,42 +31,87 @@ 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
- config = h2 .config .H2Configuration ()
41
+ with pytest .raises (ValueError ):
42
+ h2 .config .H2Configuration (** {option_name : value })
40
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
+ """
53
+ config = h2 .config .H2Configuration ()
41
54
with pytest .raises (ValueError ):
42
55
setattr (config , option_name , value )
43
56
44
57
@pytest .mark .parametrize ('option_name' , boolean_config_options )
45
58
@pytest .mark .parametrize ('value' , [True , False ])
46
- def test_boolean_config_option_is_reflected (self , option_name , value ):
59
+ def test_boolean_config_option_is_reflected_init (self , option_name , value ):
47
60
"""
48
61
The value of the boolean config options, when set, is reflected
49
- 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.
50
73
"""
51
74
config = h2 .config .H2Configuration ()
52
75
setattr (config , option_name , value )
53
76
assert getattr (config , option_name ) == value
54
77
55
78
@pytest .mark .parametrize ('header_encoding' , [True , 1 , object ()])
56
- def test_header_encoding_must_be_false_str_none (self , header_encoding ):
79
+ def test_header_encoding_must_be_false_str_none_init (
80
+ self , header_encoding
81
+ ):
57
82
"""
58
83
The value of the ``header_encoding`` setting must be False, a string,
59
- or None.
84
+ or None via the initializer .
60
85
"""
61
- config = h2 .config .H2Configuration ()
86
+ with pytest .raises (ValueError ):
87
+ h2 .config .H2Configuration (header_encoding = header_encoding )
62
88
89
+ @pytest .mark .parametrize ('header_encoding' , [True , 1 , object ()])
90
+ def test_header_encoding_must_be_false_str_none_attr (
91
+ self , header_encoding
92
+ ):
93
+ """
94
+ The value of the ``header_encoding`` setting must be False, a string,
95
+ or None via attribute setter.
96
+ """
97
+ config = h2 .config .H2Configuration ()
63
98
with pytest .raises (ValueError ):
64
99
config .header_encoding = header_encoding
65
100
66
101
@pytest .mark .parametrize ('header_encoding' , [False , 'ascii' , None ])
67
- def test_header_encoding_is_reflected (self , header_encoding ):
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
109
+
110
+ @pytest .mark .parametrize ('header_encoding' , [False , 'ascii' , None ])
111
+ def test_header_encoding_is_reflected_attr (self , header_encoding ):
68
112
"""
69
- 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.
70
115
"""
71
116
config = h2 .config .H2Configuration ()
72
117
config .header_encoding = header_encoding
0 commit comments