mirror of https://github.com/scrapy/scrapy.git
PY3 fix test middleware
This commit is contained in:
parent
683ef2a8d9
commit
8ab1648a36
|
|
@ -28,7 +28,6 @@ tests/test_engine.py
|
|||
tests/test_http_cookies.py
|
||||
tests/test_logformatter.py
|
||||
tests/test_mail.py
|
||||
tests/test_middleware.py
|
||||
tests/test_pipeline_files.py
|
||||
tests/test_pipeline_images.py
|
||||
tests/test_pipeline_media.py
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from twisted.trial import unittest
|
|||
from scrapy.settings import Settings
|
||||
from scrapy.exceptions import NotConfigured
|
||||
from scrapy.middleware import MiddlewareManager
|
||||
import six
|
||||
|
||||
class M1(object):
|
||||
|
||||
|
|
@ -65,12 +66,20 @@ class MiddlewareManagerTest(unittest.TestCase):
|
|||
|
||||
def test_methods(self):
|
||||
mwman = TestMiddlewareManager(M1(), M2(), M3())
|
||||
self.assertEqual([x.im_class for x in mwman.methods['open_spider']],
|
||||
[M1, M2])
|
||||
self.assertEqual([x.im_class for x in mwman.methods['close_spider']],
|
||||
[M2, M1])
|
||||
self.assertEqual([x.im_class for x in mwman.methods['process']],
|
||||
[M1, M3])
|
||||
if six.PY2:
|
||||
self.assertEqual([x.im_class for x in mwman.methods['open_spider']],
|
||||
[M1, M2])
|
||||
self.assertEqual([x.im_class for x in mwman.methods['close_spider']],
|
||||
[M2, M1])
|
||||
self.assertEqual([x.im_class for x in mwman.methods['process']],
|
||||
[M1, M3])
|
||||
else:
|
||||
self.assertEqual([x.__self__.__class__ for x in mwman.methods['open_spider']],
|
||||
[M1, M2])
|
||||
self.assertEqual([x.__self__.__class__ for x in mwman.methods['close_spider']],
|
||||
[M2, M1])
|
||||
self.assertEqual([x.__self__.__class__ for x in mwman.methods['process']],
|
||||
[M1, M3])
|
||||
|
||||
def test_enabled(self):
|
||||
m1, m2, m3 = M1(), M2(), M3()
|
||||
|
|
|
|||
Loading…
Reference in New Issue