From 07e0ac510cce0ae922667a1d265c85460168bc87 Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka@redhat.com>
Date: Thu, 5 Nov 2015 17:50:45 +0100
Subject: [PATCH] Skip tests that require internet if there's no connection.
---
tests/test_http.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tests/test_http.py b/tests/test_http.py
index c6b18ea..674f9eb 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -13,6 +13,7 @@ import pytest
import osbs.http as osbs_http
from osbs.http import parse_headers, HttpSession, HttpStream
+from osbs.exceptions import OsbsNetworkException
from tests.fake_api import Connection, ResponseMapping
@@ -24,6 +25,15 @@ def s():
return HttpSession(verbose=True)
+def has_connection():
+ # In case we run tests in an environment without internet connection.
+ try:
+ HttpStream("https://httpbin.org/get", "get")
+ return True
+ except OsbsNetworkException:
+ return False
+
+
class TestParseHeaders(object):
def test_parse_headers(self):
conn = Connection("0.5.4")
@@ -40,6 +50,8 @@ class TestParseHeaders(object):
assert headers["location"]
+@pytest.mark.skipif(not has_connection(),
+ reason="requires internet connection")
class TestHttpSession(object):
def test_single_multi_secure_without_redirs(self, s):
response_single = s.get("https://httpbin.org/get")
--
2.5.0