File apitools-test-disable-requires-internet.patch of Package python-google-apitools.4874
--- apitools/gen/gen_client_test.py.orig
+++ apitools/gen/gen_client_test.py
@@ -19,9 +19,16 @@ import os
import unittest2
+import urllib2
+
from apitools.gen import gen_client
from apitools.gen import test_utils
+has_network = True
+try:
+ name = urllib2.urlopen('https://www.google.com', timeout=1)
+except:
+ has_network = False
def GetTestDataPath(*path):
return os.path.join(os.path.dirname(__file__), 'testdata', *path)
@@ -44,6 +51,8 @@ class ClientGenCliTest(unittest2.TestCas
self.assertIn('error: too few arguments', err_output)
def testGenClient_SimpleDocNoInit(self):
+ if not has_network:
+ return
with test_utils.TempDir() as tmp_dir_path:
gen_client.main([
gen_client.__file__,
@@ -61,6 +70,8 @@ class ClientGenCliTest(unittest2.TestCas
self.assertEquals(expected_files, set(os.listdir(tmp_dir_path)))
def testGenClient_SimpleDocEmptyInit(self):
+ if not has_network:
+ return
with test_utils.TempDir() as tmp_dir_path:
gen_client.main([
gen_client.__file__,
@@ -117,6 +128,8 @@ __path__ = pkgutil.extend_path(__path__,
set(os.listdir(tmp_dir_path)))
def testGenPipPackage_SimpleDoc(self):
+ if not has_network:
+ return
with test_utils.TempDir() as tmp_dir_path:
gen_client.main([
gen_client.__file__,
@@ -132,6 +145,8 @@ __path__ = pkgutil.extend_path(__path__,
set(os.listdir(tmp_dir_path)))
def testGenProto_SimpleDoc(self):
+ if not has_network:
+ return
with test_utils.TempDir() as tmp_dir_path:
gen_client.main([
gen_client.__file__,
--- samples/uptodate_check_test.py.orig
+++ samples/uptodate_check_test.py
@@ -17,9 +17,16 @@ import difflib
import unittest2
+import urllib2
+
from apitools.gen import gen_client
from apitools.gen import test_utils
+has_network = True
+try:
+ name = urllib2.urlopen('https://www.google.com', timeout=1)
+except:
+ has_network = False
def GetSampleClientPath(api_name, *path):
return os.path.join(os.path.dirname(__file__), api_name + '_sample', *path)
@@ -41,6 +48,8 @@ class ClientGenCliTest(unittest2.TestCas
raise AssertionError('\n'.join(unified_diff))
def _CheckGeneratedFiles(self, api_name, api_version):
+ if not has_network:
+ return
prefix = api_name + '_' + api_version
with test_utils.TempDir() as tmp_dir_path:
gen_client.main([
--- apitools/gen/client_generation_test.py.orig
+++ apitools/gen/client_generation_test.py
@@ -19,9 +19,15 @@ import logging
import os
import subprocess
import tempfile
-
+import urllib2
import unittest2
+has_network = True
+try:
+ urllib2.urlopen('https://www.google.com', timeout=1)
+except:
+ has_network = False
+
from apitools.gen import test_utils
@@ -42,6 +48,8 @@ class ClientGenerationTest(unittest2.Tes
@test_utils.SkipOnWindows
@test_utils.RunOnlyOnPython27
def testGeneration(self):
+ if not has_network:
+ return
for api in _API_LIST:
with test_utils.TempDir(change_to=True):
args = [