From 29910ad652a9ab4cedf374e1db92143d9ddc307c Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Mon, 28 Dec 2015 22:17:30 +0000 Subject: [PATCH] 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. --- gabbi/fixture.py | 22 ---------------------- gabbi/suite.py | 6 ++++-- gabbi/tests/test_runner.py | 7 ++++--- requirements.txt | 2 +- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/gabbi/fixture.py b/gabbi/fixture.py index db948d7..ef4ffcd 100644 --- a/gabbi/fixture.py +++ b/gabbi/fixture.py @@ -17,8 +17,6 @@ import sys from unittest import case import six -import wsgi_intercept -from wsgi_intercept import httplib2_intercept class GabbiFixtureError(Exception): @@ -61,26 +59,6 @@ class GabbiFixture(object): 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): """A fixture that skips all the tests in the current suite.""" diff --git a/gabbi/suite.py b/gabbi/suite.py index 2d537da..50ebf01 100644 --- a/gabbi/suite.py +++ b/gabbi/suite.py @@ -19,6 +19,8 @@ are suite-level fixtures that operate as context managers. from unittest import case from unittest import suite +from wsgi_intercept import interceptor + from gabbi import fixture @@ -63,8 +65,8 @@ class GabbiSuite(suite.TestSuite): try: with fixture.nest([fix() for fix in fixtures]): if intercept: - with fixture.InterceptFixture(host, port, intercept, - prefix): + with interceptor.Httplib2Interceptor( + intercept, host, port, prefix): result = super(GabbiSuite, self).run(result, debug) else: result = super(GabbiSuite, self).run(result, debug) diff --git a/gabbi/tests/test_runner.py b/gabbi/tests/test_runner.py index c537de5..382e8bc 100644 --- a/gabbi/tests/test_runner.py +++ b/gabbi/tests/test_runner.py @@ -18,9 +18,9 @@ import unittest from uuid import uuid4 from six import StringIO +from wsgi_intercept.interceptor import Httplib2Interceptor from gabbi import driver -from gabbi.fixture import InterceptFixture from gabbi import handlers from gabbi import runner from gabbi.tests.simple_wsgi import SimpleWsgi @@ -36,7 +36,7 @@ class RunnerTest(unittest.TestCase): host, port = (str(uuid4()), 8000) self.host = host self.port = port - self.server = lambda: InterceptFixture(host, port, SimpleWsgi, '') + self.server = lambda: Httplib2Interceptor(SimpleWsgi, host, port, '') self._stdin = sys.stdin @@ -73,7 +73,8 @@ class RunnerTest(unittest.TestCase): self.assertSuccess(err) 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.stdin = StringIO(""" diff --git a/requirements.txt b/requirements.txt index 13b87bf..948b917 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ six PyYAML httplib2 jsonpath-rw -wsgi-intercept +wsgi-intercept>=1.0.0 colorama