Work around mocking issues on stable branches

Backports of I9dd5b97dec93c0e5393a1e7d9640f85003651b56 to stable
branches are failing CI checks because several unit tests mock
os.path.exists and would need to be updated. This does not affect master
because test code changed in I4d9f96ec4cf3c6cd0d28dfe5ddb239d863498a72.

Work around this issue by replacing os.path.exists by os.path.isfile. It
is a better check anyway since we are reading the file.

Change-Id: Ic53efd03cecbd53ad3e3b64b664e084f4e25be0e
Related-Bug: #2020135
This commit is contained in:
Pierre Riteau 2023-09-29 07:11:43 +02:00
parent 1847ad3f17
commit cfaf571794

View File

@ -54,7 +54,7 @@ def _detect_install_prefix(path):
def _get_direct_url(dist):
direct_url = os.path.join(dist._path, 'direct_url.json')
if os.path.exists(direct_url):
if os.path.isfile(direct_url):
with open(direct_url, 'r') as f:
direct_url_content = json.loads(f.readline().strip())
url = direct_url_content['url']