@@ -55,14 +55,13 @@ def test_attribute_byte(self):
55
55
actual = self .types .handle_attribute (element )
56
56
assert expected == actual
57
57
58
- def test_attribute_invalid_byte (self , capfd ):
58
+ def test_attribute_invalid_byte (self , caplog ):
59
59
"""Test parsing an invalid byte attribute."""
60
60
xml = '<attribute name="missing_value" type="byte" value="a"/>'
61
61
element = ET .fromstring (xml )
62
62
expected = {'missing_value' : ['a' ]}
63
63
actual = self .types .handle_attribute (element )
64
- expected_message = 'Cannot convert [\' a\' ] to int. Keeping type as str.'
65
- assert expected_message in '' .join (capfd .readouterr ())
64
+ assert 'Cannot convert [\' a\' ] to int. Keeping type as str.' in caplog .text
66
65
assert expected == actual
67
66
68
67
def test_attribute_short (self ):
@@ -73,14 +72,13 @@ def test_attribute_short(self):
73
72
actual = self .types .handle_attribute (element )
74
73
assert expected == actual
75
74
76
- def test_attribute_invalid_short (self , capfd ):
75
+ def test_attribute_invalid_short (self , caplog ):
77
76
"""Test parsing an invalid short attribute."""
78
77
xml = '<attribute name="missing_value" type="short" value="a"/>'
79
78
element = ET .fromstring (xml )
80
79
expected = {'missing_value' : ['a' ]}
81
80
actual = self .types .handle_attribute (element )
82
- expected_message = 'Cannot convert [\' a\' ] to int. Keeping type as str.'
83
- assert expected_message in '' .join (capfd .readouterr ())
81
+ assert 'Cannot convert [\' a\' ] to int. Keeping type as str.' in caplog .text
84
82
assert expected == actual
85
83
86
84
def test_attribute_int (self ):
@@ -91,14 +89,13 @@ def test_attribute_int(self):
91
89
actual = self .types .handle_attribute (element )
92
90
assert expected == actual
93
91
94
- def test_attribute_invalid_int (self , capfd ):
92
+ def test_attribute_invalid_int (self , caplog ):
95
93
"""Test parsing an invalid int attribute."""
96
94
xml = '<attribute name="missing_value" type="int" value="a"/>'
97
95
element = ET .fromstring (xml )
98
96
expected = {'missing_value' : ['a' ]}
99
97
actual = self .types .handle_attribute (element )
100
- expected_message = 'Cannot convert [\' a\' ] to int. Keeping type as str.'
101
- assert expected_message in '' .join (capfd .readouterr ())
98
+ assert 'Cannot convert [\' a\' ] to int. Keeping type as str.' in caplog .text
102
99
assert expected == actual
103
100
104
101
def test_attribute_long (self ):
@@ -109,14 +106,13 @@ def test_attribute_long(self):
109
106
actual = self .types .handle_attribute (element )
110
107
assert expected == actual
111
108
112
- def test_attribute_invalid_long (self , capfd ):
109
+ def test_attribute_invalid_long (self , caplog ):
113
110
"""Test parsing a invalid long attribute."""
114
111
xml = '<attribute name="missing_value" type="long" value="a"/>'
115
112
element = ET .fromstring (xml )
116
113
expected = {'missing_value' : ['a' ]}
117
114
actual = self .types .handle_attribute (element )
118
- expected_message = 'Cannot convert [\' a\' ] to int. Keeping type as str.'
119
- assert expected_message in '' .join (capfd .readouterr ())
115
+ assert 'Cannot convert [\' a\' ] to int. Keeping type as str.' in caplog .text
120
116
assert expected == actual
121
117
122
118
def test_attribute_float (self ):
@@ -127,14 +123,13 @@ def test_attribute_float(self):
127
123
actual = self .types .handle_attribute (element )
128
124
assert expected == actual
129
125
130
- def test_attribute_invalid_float (self , capfd ):
126
+ def test_attribute_invalid_float (self , caplog ):
131
127
"""Test parsing an invalid float value attribute."""
132
128
xml = '<attribute name="missing_value" type="float" value="a"/>'
133
129
element = ET .fromstring (xml )
134
130
expected = {'missing_value' : ['a' ]}
135
131
actual = self .types .handle_attribute (element )
136
- expected_message = 'Cannot convert [\' a\' ] to float. Keeping type as str.'
137
- assert expected_message in '' .join (capfd .readouterr ())
132
+ assert 'Cannot convert [\' a\' ] to float. Keeping type as str.' in caplog .text
138
133
assert expected == actual
139
134
140
135
def test_attribute_float_nan (self ):
@@ -156,14 +151,13 @@ def test_attribute_double(self):
156
151
actual = self .types .handle_attribute (element )
157
152
assert expected == actual
158
153
159
- def test_attribute_invalid_double (self , capfd ):
154
+ def test_attribute_invalid_double (self , caplog ):
160
155
"""Test parsing an invalid double attribute."""
161
156
xml = '<attribute name="missing_value" type="double" value="a"/>'
162
157
element = ET .fromstring (xml )
163
158
expected = {'missing_value' : ['a' ]}
164
159
actual = self .types .handle_attribute (element )
165
- expected_message = 'Cannot convert [\' a\' ] to float. Keeping type as str.'
166
- assert expected_message in '' .join (capfd .readouterr ())
160
+ assert 'Cannot convert [\' a\' ] to float. Keeping type as str.' in caplog .text
167
161
assert expected == actual
168
162
169
163
def test_attribute_double_nan (self ):
@@ -210,15 +204,13 @@ def test_attribute_boolean_false(self):
210
204
actual = self .types .handle_attribute (element )
211
205
assert expected == actual
212
206
213
- def test_attribute_boolean_invalid (self , capfd ):
207
+ def test_attribute_boolean_invalid (self , caplog ):
214
208
"""Test parsing an invalid boolean attribute."""
215
209
xml = '<attribute name="missing_value" type="boolean" value="a"/>'
216
210
element = ET .fromstring (xml )
217
211
expected = {'missing_value' : ['a' ]}
218
212
actual = self .types .handle_attribute (element )
219
- expected_message = 'Cannot convert values [\' a\' ] to boolean.'
220
- expected_message += ' Keeping type as str.'
221
- assert expected_message in '' .join (capfd .readouterr ())
213
+ assert 'Cannot convert values [\' a\' ] to boolean. Keeping type as str.' in caplog .text
222
214
assert expected == actual
223
215
224
216
def test_value_1 (self ):
0 commit comments