coding utf8 from captcha_solver import CaptchaSolver from functools im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# coding:utf8
from captcha_solver import CaptchaSolver
from functools import partial
from mock import patch, Mock
from grab import Grab
import logging
logging.basicConfig(leve=logging.DEBUG)
def request(self):
self.response.body = 'OK|captcha_id'
self.response.code = 200
g = Grab()
with patch.object(Grab, 'request') as mock_method:
mock_method.side_effect = partial(request, g)
g.request()
print g.response.code
print g.response.body