22
22
import sys
23
23
import tempfile
24
24
import unittest
25
-
25
+ from http . server import HTTPStatus
26
26
from unittest .mock import patch
27
27
from urllib .error import HTTPError
28
28
from urllib .request import Request
31
31
import pytest
32
32
from xdg import BaseDirectory
33
33
34
- from fades import HTTP_STATUS_NOT_FOUND , HTTP_STATUS_OK , helpers
35
- from fades import parsing
34
+ from fades import helpers , parsing
36
35
37
36
38
37
PATH_TO_EXAMPLES = "tests/examples/"
@@ -307,7 +306,7 @@ def test_exists(self):
307
306
308
307
with patch ('urllib.request.urlopen' ) as mock_urlopen :
309
308
with patch ('http.client.HTTPResponse' ) as mock_http_response :
310
- mock_http_response .status = HTTP_STATUS_OK
309
+ mock_http_response .status = HTTPStatus . OK
311
310
mock_urlopen .return_value = mock_http_response
312
311
313
312
exists = helpers .check_pypi_exists (deps )
@@ -319,7 +318,7 @@ def test_all_exists(self):
319
318
320
319
with patch ('urllib.request.urlopen' ) as mock_urlopen :
321
320
with patch ('http.client.HTTPResponse' ) as mock_http_response :
322
- mock_http_response .status = HTTP_STATUS_OK
321
+ mock_http_response .status = HTTPStatus . OK
323
322
mock_urlopen .side_effect = [mock_http_response ] * 3
324
323
325
324
exists = helpers .check_pypi_exists (dependencies )
@@ -330,7 +329,7 @@ def test_doesnt_exists(self):
330
329
dependency = parsing .parse_manual (["foo" ])
331
330
332
331
with patch ('urllib.request.urlopen' ) as mock_urlopen :
333
- mock_http_error = HTTPError ("url" , HTTP_STATUS_NOT_FOUND , "mgs" , {}, io .BytesIO ())
332
+ mock_http_error = HTTPError ("url" , HTTPStatus . NOT_FOUND , "mgs" , {}, io .BytesIO ())
334
333
mock_urlopen .side_effect = mock_http_error
335
334
336
335
exists = helpers .check_pypi_exists (dependency )
@@ -343,8 +342,8 @@ def test_one_doesnt_exists(self):
343
342
344
343
with patch ('urllib.request.urlopen' ) as mock_urlopen :
345
344
with patch ('http.client.HTTPResponse' ) as mock_http_response :
346
- mock_http_error = HTTPError ("url" , HTTP_STATUS_NOT_FOUND , "mgs" , {}, io .BytesIO ())
347
- mock_http_response .status = HTTP_STATUS_OK
345
+ mock_http_error = HTTPError ("url" , HTTPStatus . NOT_FOUND , "mgs" , {}, io .BytesIO ())
346
+ mock_http_response .status = HTTPStatus . OK
348
347
mock_urlopen .side_effect = [mock_http_response , mock_http_error ]
349
348
350
349
exists = helpers .check_pypi_exists (dependencies )
0 commit comments