Skip to content

Commit

Permalink
<class 'NoneType'> vs. <type 'NoneType'>
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Oct 10, 2020
1 parent 2b7c65e commit 216d9cd
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/treq/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,8 @@ def test_request_headers_invalid_type(self):

[w] = self.flushWarnings([self.test_request_headers_invalid_type])
self.assertEqual(DeprecationWarning, w['category'])
self.assertEqual(
(
"headers must be a dict, twisted.web.http_headers.Headers, or None,"
" but found <class 'list'>, which will be ignored. This will raise"
" TypeError in the next treq release."
),
self.assertIn(
"headers must be a dict, twisted.web.http_headers.Headers, or None,",
w['message'],
)

Expand All @@ -544,25 +540,18 @@ def test_request_dict_headers_invalid_values(self):
self.client.request('GET', 'http://example.com', headers=OrderedDict([
('none', None),
('one', 1),
('ok', 'string'),
]))

[w1, w2] = self.flushWarnings([self.test_request_dict_headers_invalid_values])
self.assertEqual(DeprecationWarning, w1['category'])
self.assertEqual(DeprecationWarning, w2['category'])
self.assertEqual(
(
"The value of headers key 'none' has non-string type"
" <class 'NoneType'> and will be dropped. This will raise TypeError"
" in the next treq release."
),
self.assertIn(
"The value of headers key 'none' has non-string type",
w1['message'],
)
self.assertEqual(
(
"The value of headers key 'one' has non-string type"
" <class 'int'> and will be dropped. This will raise TypeError"
" in the next treq release."
),
self.assertIn(
"The value of headers key 'one' has non-string type",
w2['message'],
)

Expand Down

0 comments on commit 216d9cd

Please sign in to comment.