2017-05-23 03:59:55 +01:00
|
|
|
import time
|
|
|
|
import json
|
|
|
|
import shlex
|
|
|
|
import subprocess
|
|
|
|
import urllib.request
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def gunicorn_worker():
|
|
|
|
command = 'gunicorn --bind 127.0.0.1:1337 --worker-class sanic.worker.GunicornWorker examples.simple_server:app'
|
|
|
|
worker = subprocess.Popen(shlex.split(command))
|
2017-06-11 17:06:48 +01:00
|
|
|
time.sleep(3)
|
2017-05-23 03:59:55 +01:00
|
|
|
yield
|
|
|
|
worker.kill()
|
|
|
|
|
|
|
|
|
|
|
|
def test_gunicorn_worker(gunicorn_worker):
|
|
|
|
with urllib.request.urlopen('http://localhost:1337/') as f:
|
|
|
|
res = json.loads(f.read(100).decode())
|
|
|
|
assert res['test']
|