def test_not_enabled(self): crawler = get_crawler(Spider, {'HTTPPROXY_ENABLED': False}) with pytest.raises(NotConfigured): HttpProxyMiddleware.from_crawler(crawler)