8000 fix test failures · pypa/pip@1d05011 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d05011

Browse files
fix test failures
1 parent 9cf718c commit 1d05011

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/pip/_internal/index/collector.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@
88
import mimetypes
99
import os
1010
from collections import OrderedDict
11-
from functools import lru_cache
11+
12+
try:
13+
from functools import lru_cache
14+
except ImportError:
15+
# Only works for single-argument functions.
16+
def lru_cache(*args, **kwargs):
17+
cache = {}
18+
def wrapper(fn):
19+
def wrapped(arg):
20+
value = cache.get(arg, None)
21+
if value is not None:
22+
return value
23+
value = fn(arg)
24+
cache[arg] = value
25+
return value
26+
return wrapped
27+
return wrapper
1228

1329
from pip._vendor import html5lib, requests
1430
from pip._vendor.distlib.compat import unescape

tests/unit/test_collector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ def test_parse_links_caches_same_page():
290290
page_1 = HTMLPage(
291291
html_bytes,
292292
encoding=None,
293-
url='https://example.com/simple/',
293+
url='https://example.com/some-find-links-url/',
294294
)
295295
page_2 = HTMLPage(
296296
html_bytes,
297297
encoding=None,
298-
url='https://example.com/simple/',
298+
url='https://example.com/some-find-links-url/',
299299
)
300300

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

0 commit comments

Comments
 (0)
0