fix: flake8 errors in tests/
This commit is contained in:
@@ -14,9 +14,11 @@ now = datetime.utcnow()
|
||||
url = "https://example.com/"
|
||||
user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||
|
||||
rndstr = lambda n: "".join(
|
||||
|
||||
def rndstr(n):
|
||||
return "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_oldest():
|
||||
@@ -58,7 +60,7 @@ def test_invalid_json():
|
||||
"""
|
||||
with pytest.raises(InvalidJSONInAvailabilityAPIResponse):
|
||||
availability_api = WaybackMachineAvailabilityAPI(url="", user_agent=user_agent)
|
||||
archive_url = availability_api.archive_url
|
||||
_ = availability_api.archive_url
|
||||
|
||||
|
||||
def test_no_archive():
|
||||
@@ -74,7 +76,7 @@ def test_no_archive():
|
||||
availability_api = WaybackMachineAvailabilityAPI(
|
||||
url="https://%s.cn" % rndstr(30), user_agent=user_agent
|
||||
)
|
||||
archive_url = availability_api.archive_url
|
||||
_ = availability_api.archive_url
|
||||
|
||||
|
||||
def test_no_api_call_str_repr():
|
||||
|
@@ -1,7 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from waybackpy.cdx_snapshot import CDXSnapshot
|
||||
|
||||
|
||||
|
@@ -87,10 +87,10 @@ def test_check_collapses():
|
||||
|
||||
|
||||
def test_check_match_type():
|
||||
assert None == check_match_type(None, "url")
|
||||
assert check_match_type(None, "url") is None
|
||||
match_type = "exact"
|
||||
url = "test_url"
|
||||
assert None == check_match_type(match_type, url)
|
||||
assert check_match_type(match_type, url) is None
|
||||
|
||||
url = "has * in it"
|
||||
with pytest.raises(WaybackError):
|
||||
|
@@ -8,9 +8,11 @@ import pytest
|
||||
from waybackpy.exceptions import MaximumSaveRetriesExceeded
|
||||
from waybackpy.save_api import WaybackMachineSaveAPI
|
||||
|
||||
rndstr = lambda n: "".join(
|
||||
|
||||
def rndstr(n):
|
||||
return "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_save():
|
||||
@@ -24,8 +26,9 @@ def test_save():
|
||||
cached_save = save_api.cached_save
|
||||
assert cached_save in [True, False]
|
||||
assert archive_url.find("github.com/akamhy/waybackpy") != -1
|
||||
assert timestamp is not None
|
||||
assert str(headers).find("github.com/akamhy/waybackpy") != -1
|
||||
assert type(save_api.timestamp()) == type(datetime(year=2020, month=10, day=2))
|
||||
assert isinstance(save_api.timestamp(), datetime.datetime)
|
||||
|
||||
|
||||
def test_max_redirect_exceeded():
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from waybackpy.__version__ import __version__
|
||||
from waybackpy import __version__
|
||||
from waybackpy.utils import (
|
||||
DEFAULT_USER_AGENT,
|
||||
latest_version_github,
|
||||
|
Reference in New Issue
Block a user