Commit 55c52bb6 authored by Rémi Duraffort's avatar Rémi Duraffort Committed by Neil Williams

LAVA-1156 When running under pytest, fake requests

The lava_dispatcher test suite is now faster and resilient to network errors.
Some tests (listed in that do require network access can still use
the network.

Change-Id: I4df941df68df3ac3dd2a8baf617e2dd68cc2ed80
parent c6d61c0e
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Linaro Limited
# Author: Remi Duraffort <>
# This file is part of LAVA.
# LAVA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# LAVA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along
# with this program; if not, see <>.
import pytest
import requests
def no_requests(monkeypatch, request):
def get(url, allow_redirects, stream):
assert allow_redirects is True
assert stream is True
res = requests.Response()
res.status_code =
res.close = lambda: None
return res
# List of tests that should have access to the network
# When pytest is mandatory, we can use pytest marks
# See
skip_tests = ["test_download_decompression", "TestChecksum", "test_xz_nfs"]
if set(skip_tests) & set(request.keywords.keys()):
monkeypatch.setattr(requests, "get", get)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment