Skip to content

Commit

Permalink
handle urlparse API change in Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ktdreyer committed Nov 29, 2015
1 parent bb58a0c commit 176ac61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions nfsn/auth.py
Expand Up @@ -4,7 +4,11 @@
import requests
import string
import time
import urlparse
try:
from urllib.parse import urlparse
except ImportError:
# Python 2
from urlparse import urlparse

logging.basicConfig(level=logging.WARNING)
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -43,7 +47,7 @@ def _header(self, r):
timestamp = self._timestamp()
salt = self._salt()
api_key = self.api_key
request_uri = urlparse.urlparse(r.url).path
request_uri = urlparse(r.url).path
body_hash = hashlib.sha1(r.body or '').hexdigest()

log.debug("login: %s", login)
Expand Down
8 changes: 6 additions & 2 deletions nfsn/tests/test_api.py
Expand Up @@ -4,7 +4,11 @@
import pytest
import re
from shutil import copyfile
import urlparse
try:
from urllib.parse import urlparse
except ImportError:
# Python 2
from urlparse import urlparse

tests_dir = os.path.dirname(os.path.abspath(__file__))
fixtures_dir = os.path.join(tests_dir, 'fixtures')
Expand All @@ -28,7 +32,7 @@ def get_request_callback(request, uri, headers):
# The response bodies are stored in flat files under the
# "fixtures/payloads" directory (fixtures_dir).
# E.g. tests/fixtures/payloads/dns/example.com/listRRs
request_path = urlparse.urlparse(uri).path
request_path = urlparse(uri).path
payload_file = fixtures_dir + '/responses/' + request_path

with open(payload_file) as data_file:
Expand Down

0 comments on commit 176ac61

Please sign in to comment.