Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Feb 13, 2020
1 parent 9cf718c commit 1d05011
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/pip/_internal/index/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@
import mimetypes
import os
from collections import OrderedDict
from functools import lru_cache

try:
from functools import lru_cache
except ImportError:
# Only works for single-argument functions.
def lru_cache(*args, **kwargs):
cache = {}
def wrapper(fn):
def wrapped(arg):
value = cache.get(arg, None)
if value is not None:
return value
value = fn(arg)
cache[arg] = value
return value
return wrapped
return wrapper

from pip._vendor import html5lib, requests
from pip._vendor.distlib.compat import unescape
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ def test_parse_links_caches_same_page():
page_1 = HTMLPage(
html_bytes,
encoding=None,
url='https://example.com/simple/',
url='https://example.com/some-find-links-url/',
)
page_2 = HTMLPage(
html_bytes,
encoding=None,
url='https://example.com/simple/',
url='https://example.com/some-find-links-url/',
)

with mock.patch("pip._internal.index.collector.html5lib.parse") as mock_parse:
Expand Down

0 comments on commit 1d05011

Please sign in to comment.