From f03560b9041168564b8d9634391d4df8a2570848 Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Wed, 22 Apr 2015 15:24:29 +0800 Subject: [PATCH] [fix] unit test failure --- pyswagger/tests/v1_2/test_app.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pyswagger/tests/v1_2/test_app.py b/pyswagger/tests/v1_2/test_app.py index 86234a4..638b0e2 100644 --- a/pyswagger/tests/v1_2/test_app.py +++ b/pyswagger/tests/v1_2/test_app.py @@ -1,4 +1,4 @@ -from pyswagger import SwaggerApp, errs +from pyswagger import SwaggerApp, errs, utils from ..utils import get_test_data_folder from pyswagger.spec.v2_0.objects import ( Schema, @@ -128,14 +128,11 @@ def setUp(self): ) def _hook(url): + # a demo of hooking a remote url to local path p = six.moves.urllib.parse.urlparse(url) - if p.scheme != 'file': - return url + return utils.normalize_url(os.path.join(folder, p.path[1:])) - path = os.path.join(folder, p.path if not p.path.startswith('/') else p.path[1:]) - return six.moves.urllib.parse.urlunparse(p[:2]+(path,)+p[3:]) - - self.app = SwaggerApp.load('wordnik', url_load_hook=_hook) + self.app = SwaggerApp.load('http://petstore.io/wordnik', url_load_hook=_hook) self.app.prepare() def test_ref(self): @@ -154,11 +151,11 @@ def test_ref(self): # for how to dereferencing weakref self.assertEqual( self.app.resolve('#/definitions/user!##!User').__repr__(), - self.app.resolve('file:///wordnik#/definitions/user!##!User').__repr__() + self.app.resolve('http://petstore.io/wordnik#/definitions/user!##!User').__repr__() ) self.assertEqual( self.app.resolve('#/paths/~1api~1user~1{username}/put').__repr__(), - self.app.resolve('file:///wordnik#/paths/~1api~1user~1{username}/put').__repr__() + self.app.resolve('http://petstore.io/wordnik#/paths/~1api~1user~1{username}/put').__repr__() ) def test_scope_dict(self):