Use the Interceptor class from wsgi_intercept
The new version of wsgi_intercept has a class which provides the same functionality as gabbi's InterceptFixture. That has been removed.
This commit is contained in:
parent
398fe696a7
commit
29910ad652
@ -17,8 +17,6 @@ import sys
|
|||||||
from unittest import case
|
from unittest import case
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import wsgi_intercept
|
|
||||||
from wsgi_intercept import httplib2_intercept
|
|
||||||
|
|
||||||
|
|
||||||
class GabbiFixtureError(Exception):
|
class GabbiFixtureError(Exception):
|
||||||
@ -61,26 +59,6 @@ class GabbiFixture(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class InterceptFixture(GabbiFixture):
|
|
||||||
"""Start up the wsgi intercept. This should not be called directly."""
|
|
||||||
|
|
||||||
httplib2_intercept.install()
|
|
||||||
|
|
||||||
def __init__(self, host, port, app, prefix):
|
|
||||||
super(InterceptFixture, self).__init__()
|
|
||||||
self.host = host
|
|
||||||
self.port = int(port)
|
|
||||||
self.app = app
|
|
||||||
self.script_name = prefix or ''
|
|
||||||
|
|
||||||
def start_fixture(self):
|
|
||||||
wsgi_intercept.add_wsgi_intercept(self.host, self.port, self.app,
|
|
||||||
script_name=self.script_name)
|
|
||||||
|
|
||||||
def stop_fixture(self):
|
|
||||||
wsgi_intercept.remove_wsgi_intercept(self.host, self.port)
|
|
||||||
|
|
||||||
|
|
||||||
class SkipAllFixture(GabbiFixture):
|
class SkipAllFixture(GabbiFixture):
|
||||||
"""A fixture that skips all the tests in the current suite."""
|
"""A fixture that skips all the tests in the current suite."""
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ are suite-level fixtures that operate as context managers.
|
|||||||
from unittest import case
|
from unittest import case
|
||||||
from unittest import suite
|
from unittest import suite
|
||||||
|
|
||||||
|
from wsgi_intercept import interceptor
|
||||||
|
|
||||||
from gabbi import fixture
|
from gabbi import fixture
|
||||||
|
|
||||||
|
|
||||||
@ -63,8 +65,8 @@ class GabbiSuite(suite.TestSuite):
|
|||||||
try:
|
try:
|
||||||
with fixture.nest([fix() for fix in fixtures]):
|
with fixture.nest([fix() for fix in fixtures]):
|
||||||
if intercept:
|
if intercept:
|
||||||
with fixture.InterceptFixture(host, port, intercept,
|
with interceptor.Httplib2Interceptor(
|
||||||
prefix):
|
intercept, host, port, prefix):
|
||||||
result = super(GabbiSuite, self).run(result, debug)
|
result = super(GabbiSuite, self).run(result, debug)
|
||||||
else:
|
else:
|
||||||
result = super(GabbiSuite, self).run(result, debug)
|
result = super(GabbiSuite, self).run(result, debug)
|
||||||
|
@ -18,9 +18,9 @@ import unittest
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from six import StringIO
|
from six import StringIO
|
||||||
|
from wsgi_intercept.interceptor import Httplib2Interceptor
|
||||||
|
|
||||||
from gabbi import driver
|
from gabbi import driver
|
||||||
from gabbi.fixture import InterceptFixture
|
|
||||||
from gabbi import handlers
|
from gabbi import handlers
|
||||||
from gabbi import runner
|
from gabbi import runner
|
||||||
from gabbi.tests.simple_wsgi import SimpleWsgi
|
from gabbi.tests.simple_wsgi import SimpleWsgi
|
||||||
@ -36,7 +36,7 @@ class RunnerTest(unittest.TestCase):
|
|||||||
host, port = (str(uuid4()), 8000)
|
host, port = (str(uuid4()), 8000)
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
self.server = lambda: InterceptFixture(host, port, SimpleWsgi, '')
|
self.server = lambda: Httplib2Interceptor(SimpleWsgi, host, port, '')
|
||||||
|
|
||||||
self._stdin = sys.stdin
|
self._stdin = sys.stdin
|
||||||
|
|
||||||
@ -73,7 +73,8 @@ class RunnerTest(unittest.TestCase):
|
|||||||
self.assertSuccess(err)
|
self.assertSuccess(err)
|
||||||
|
|
||||||
def test_target_url_parsing_standard_port(self):
|
def test_target_url_parsing_standard_port(self):
|
||||||
self.server = lambda: InterceptFixture(self.host, 80, SimpleWsgi, '')
|
self.server = lambda: Httplib2Interceptor(
|
||||||
|
SimpleWsgi, self.host, 80, '')
|
||||||
sys.argv = ['gabbi-run', 'http://%s/foo' % self.host]
|
sys.argv = ['gabbi-run', 'http://%s/foo' % self.host]
|
||||||
|
|
||||||
sys.stdin = StringIO("""
|
sys.stdin = StringIO("""
|
||||||
|
@ -3,5 +3,5 @@ six
|
|||||||
PyYAML
|
PyYAML
|
||||||
httplib2
|
httplib2
|
||||||
jsonpath-rw
|
jsonpath-rw
|
||||||
wsgi-intercept
|
wsgi-intercept>=1.0.0
|
||||||
colorama
|
colorama
|
||||||
|
Loading…
Reference in New Issue
Block a user