Skip to content

Commit

Permalink
Update asserts to use more generic ones
Browse files Browse the repository at this point in the history
  • Loading branch information
ngash authored and redapple committed Aug 9, 2017
1 parent 4ca61a2 commit fd27cde
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/test_http_cookies.py
Expand Up @@ -62,7 +62,7 @@ def setUp(self):
self.wrapped = WrappedResponse(self.response)

def test_info(self):
self.assertTrue(self.wrapped.info() is self.wrapped)
self.assertIs(self.wrapped.info(), self.wrapped)

def test_getheaders(self):
self.assertEqual(self.wrapped.getheaders('content-type'), ['text/html'])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_http_request.py
Expand Up @@ -64,9 +64,9 @@ def test_headers(self):
h = Headers({'key1': u'val1', u'key2': 'val2'})
h[u'newkey'] = u'newval'
for k, v in h.iteritems():
self.assertTrue(isinstance(k, bytes))
self.assertIsInstance(k, bytes)
for s in v:
self.assertTrue(isinstance(s, bytes))
self.assertIsInstance(s, bytes)

def test_eq(self):
url = 'http://www.scrapy.org'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_loader.py
Expand Up @@ -437,7 +437,7 @@ def test_join(self):
self.assertRaises(TypeError, proc, [None, '', 'hello', 'world'])
self.assertEqual(proc(['', 'hello', 'world']), u' hello world')
self.assertEqual(proc(['hello', 'world']), u'hello world')
self.assertTrue(isinstance(proc(['hello', 'world']), six.text_type))
self.assertIsInstance(proc(['hello', 'world']), six.text_type)

def test_compose(self):
proc = Compose(lambda v: v[0], str.upper)
Expand Down Expand Up @@ -482,15 +482,15 @@ def test_constructor_errors(self):
def test_constructor_with_selector(self):
sel = Selector(text=u"<html><body><div>marta</div></body></html>")
l = TestItemLoader(selector=sel)
self.assertTrue(l.selector is sel)
self.assertIs(l.selector, sel)

l.add_xpath('name', '//div/text()')
self.assertEqual(l.get_output_value('name'), [u'Marta'])

def test_constructor_with_selector_css(self):
sel = Selector(text=u"<html><body><div>marta</div></body></html>")
l = TestItemLoader(selector=sel)
self.assertTrue(l.selector is sel)
self.assertIs(l.selector, sel)

l.add_css('name', 'div::text')
self.assertEqual(l.get_output_value('name'), [u'Marta'])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils_python.py
Expand Up @@ -156,7 +156,7 @@ def test_stringify_dict(self):
d = {'a': 123, u'b': b'c', u'd': u'e', object(): u'e'}
d2 = stringify_dict(d, keys_only=False)
self.assertEqual(d, d2)
self.assertFalse(d is d2) # shouldn't modify in place
self.assertIsNot(d, d2) # shouldn't modify in place
self.assertFalse(any(isinstance(x, six.text_type) for x in d2.keys()))
self.assertFalse(any(isinstance(x, six.text_type) for x in d2.values()))

Expand All @@ -166,7 +166,7 @@ def test_stringify_dict_tuples(self):
d = dict(tuples)
d2 = stringify_dict(tuples, keys_only=False)
self.assertEqual(d, d2)
self.assertFalse(d is d2) # shouldn't modify in place
self.assertIsNot(d, d2) # shouldn't modify in place
self.assertFalse(any(isinstance(x, six.text_type) for x in d2.keys()), d2.keys())
self.assertFalse(any(isinstance(x, six.text_type) for x in d2.values()))

Expand All @@ -175,7 +175,7 @@ def test_stringify_dict_keys_only(self):
d = {'a': 123, u'b': 'c', u'd': u'e', object(): u'e'}
d2 = stringify_dict(d)
self.assertEqual(d, d2)
self.assertFalse(d is d2) # shouldn't modify in place
self.assertIsNot(d, d2) # shouldn't modify in place
self.assertFalse(any(isinstance(x, six.text_type) for x in d2.keys()))

def test_get_func_args(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils_signal.py
Expand Up @@ -29,7 +29,7 @@ def test_send_catch_log(self):
self.assertIn('error_handler', record.getMessage())
self.assertEqual(record.levelname, 'ERROR')
self.assertEqual(result[0][0], self.error_handler)
self.assertTrue(isinstance(result[0][1], Failure))
self.assertIsInstance(result[0][1], Failure)
self.assertEqual(result[1], (self.ok_handler, "OK"))

dispatcher.disconnect(self.error_handler, signal=test_signal)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_webclient.py
Expand Up @@ -326,7 +326,7 @@ def testNotFound(self):
return getPage(self.getURL('notsuchfile')).addCallback(self._cbNoSuchFile)

def _cbNoSuchFile(self, pageData):
self.assertTrue(b'404 - No Such Resource' in pageData)
self.assertIn(b'404 - No Such Resource', pageData)

def testFactoryInfo(self):
url = self.getURL('file')
Expand Down

0 comments on commit fd27cde

Please sign in to comment.