Форум сайта python.su
Маю функцію яка робить шось таке:
URL = 'http://localhost:8080'
def func():
response = urlopen(URL)
return process(response)
from wsgiref.simple_server import make_server
def app_200_hello(environ,start_response):
stdout = StringIO('Hello world')
start_response("200 OK", [('Content-Type','text/plain')])
return [stdout.getvalue()]
s = make_server('localhost', 8080, app_200_hello)
class TestFunc(unittest.TestCase):
def setUp(self):
s.handle_request()
def test1(self):
r = func()
assert r, something
if __name__ == '__main__':
unittest.main()
Офлайн
Офлайн