Skip to content

Commit f1c410f

Browse files
Merge pull request #93 from allrob23/master
Ensure trailing slashes in session.mount() URLs
2 parents 678af39 + 694f236 commit f1c410f

File tree

1 file changed

+8
-1
lines changed
  • stackinabox/util/requests_mock

1 file changed

+8
-1
lines changed

stackinabox/util/requests_mock/core.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
from requests.adapters import HTTPAdapter
1818
from urllib3.response import HTTPResponse
1919
import requests_mock
20-
import requests_mock.compat
2120
import requests_mock.response
2221
import six
2322

2423
from stackinabox.stack import StackInABox
2524
from stackinabox.util import deprecator
2625
from stackinabox.util.requests_mock import reqcallable
2726

27+
try:
28+
import requests_mock.compat
29+
except ImportError:
30+
pass
31+
2832

2933
logger = logging.getLogger(__name__)
3034

@@ -52,6 +56,9 @@ def session_registration(uri, session):
5256
reqcallable.RequestMockCallable(uri)
5357
)
5458

59+
if not uri.endswith('/'):
60+
uri += '/'
61+
5562
# Tell the session about the adapter and the URI
5663
session.mount('http://{0}'.format(uri), StackInABox.hold_out('adapter'))
5764
session.mount('https://{0}'.format(uri), StackInABox.hold_out('adapter'))

0 commit comments

Comments
 (0)