Fixing bug of trailing slash. closes #73
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import inspect
|
||||
import socket
|
||||
import functools
|
||||
@@ -662,6 +663,11 @@ class httpretty(HttpBaseClass):
|
||||
status=200,
|
||||
responses=None, **headers):
|
||||
|
||||
uri_is_string = isinstance(uri, basestring)
|
||||
|
||||
if uri_is_string and re.search(r'^\w+://[^/]+[.]\w{2,}$', uri):
|
||||
uri += '/'
|
||||
|
||||
if isinstance(responses, list) and len(responses) > 0:
|
||||
for response in responses:
|
||||
response.uri = uri
|
||||
|
||||
@@ -617,3 +617,12 @@ def test_httpretty_should_normalize_url_patching():
|
||||
|
||||
response = requests.get('http://yipit.com/foo%28bar%29')
|
||||
expect(response.text).to.equal('Find the best daily deals')
|
||||
|
||||
|
||||
@httprettified
|
||||
def test_lack_of_trailing_slash():
|
||||
("HTTPretty should automatically append a slash to given urls")
|
||||
url = 'http://www.youtube.com'
|
||||
HTTPretty.register_uri(HTTPretty.GET, url, body='')
|
||||
response = requests.get(url)
|
||||
response.status_code.should.equal(200)
|
||||
|
||||
Reference in New Issue
Block a user