Skip to content

Commit 94f9939

Browse files
committed
Use requests throughout test_pr
1 parent 0642eb8 commit 94f9939

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tools/test_pr.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
import requests
1717
import shutil
1818
from subprocess import call, check_call, check_output, PIPE, STDOUT, CalledProcessError
19-
try:
20-
from urllib.request import urlopen
21-
except ImportError:
22-
from urllib2 import urlopen
2319

2420
import gh_auth
2521

@@ -72,8 +68,7 @@ def setup():
7268

7369
def get_pull_request(num):
7470
url = "https://api.github.com/repos/{project}/pulls/{num}".format(project=gh_project, num=num)
75-
response = urlopen(url).read().decode('utf-8')
76-
return json.loads(response)
71+
return json.loads(requests.get(url).text)
7772

7873
missing_libs_re = re.compile(r"Tools and libraries NOT available at test time:\n"
7974
r"\s*(.*?)\n")
@@ -125,8 +120,8 @@ def post_gist(content, description='IPython test log', filename="results.log"):
125120
}
126121
}).encode('utf-8')
127122

128-
response = urlopen("https://api.github.com/gists", post_data)
129-
response_data = json.loads(response.read().decode('utf-8'))
123+
response = requests.post("https://api.github.com/gists", data=post_data)
124+
response_data = json.loads(response.text)
130125
return response_data['html_url']
131126

132127
def markdown_format(pr, results):
@@ -159,7 +154,7 @@ def post_results_comment(pr, results, num):
159154
auth_token = gh_auth.get_auth_token()
160155
headers = {'Authorization': 'token ' + auth_token}
161156
r = requests.post(url, data=payload, headers=headers)
162-
157+
163158

164159
if __name__ == '__main__':
165160
import sys

0 commit comments

Comments
 (0)