summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Illfelder <illfelder@users.noreply.github.com>2016-05-04 10:44:22 -0700
committerMax Illfelder <illfelder@users.noreply.github.com>2016-05-04 10:44:22 -0700
commit8e9e2006fe30dbef2e16365bf3f272863f467e05 (patch)
tree3981c564d960a18c6abe6d41f83584cc313e0d05
parentcd9b2f79c5ca14735d1afa53f10fd6ca2f27b772 (diff)
parentb4bad75ef148e730b72a46661d15ed55f8275f6b (diff)
downloadgoogle-compute-image-packages-8e9e2006fe30dbef2e16365bf3f272863f467e05.tar.gz
Merge pull request #227 from illfelder/development
Python 2.6 support for Linux guest testing.
-rw-r--r--.travis.yml5
-rw-r--r--google_compute_engine/accounts/tests/accounts_daemon_test.py10
-rw-r--r--google_compute_engine/accounts/tests/accounts_utils_test.py2
-rw-r--r--google_compute_engine/boto/compute_auth.py4
-rw-r--r--google_compute_engine/boto/tests/boto_config_test.py3
-rw-r--r--google_compute_engine/boto/tests/compute_auth_test.py3
-rw-r--r--google_compute_engine/clock_skew/tests/clock_skew_daemon_test.py2
-rw-r--r--google_compute_engine/compat.py6
-rw-r--r--google_compute_engine/instance_setup/tests/instance_setup_test.py2
-rw-r--r--google_compute_engine/ip_forwarding/tests/ip_forwarding_daemon_test.py3
-rw-r--r--google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py3
-rw-r--r--google_compute_engine/metadata_scripts/tests/script_executor_test.py2
-rw-r--r--google_compute_engine/metadata_scripts/tests/script_manager_test.py3
-rw-r--r--google_compute_engine/metadata_scripts/tests/script_retriever_test.py4
-rw-r--r--google_compute_engine/tests/config_manager_test.py3
-rw-r--r--google_compute_engine/tests/lock_file_test.py3
-rw-r--r--google_compute_engine/tests/logger_test.py3
-rw-r--r--google_compute_engine/tests/metadata_watcher_test.py2
18 files changed, 32 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml
index f6f7b5b..cc5b132 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,7 @@
language: python
sudo: true
python:
+ - 2.6
- 2.7
- 3.2
- 3.3
@@ -14,9 +15,11 @@ env:
- BOTO_CONFIG=/tmp/fake
os:
- linux
-# python3.2 does not have mock installed by default.
+# Python 2.6 uses a backported version of unittest.
+# Python 3.2 does not have mock installed by default.
install:
- pip install boto
+ - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install unittest2; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then pip3.2 install mock; fi
# nosetests will run all tests within the current directory.
script:
diff --git a/google_compute_engine/accounts/tests/accounts_daemon_test.py b/google_compute_engine/accounts/tests/accounts_daemon_test.py
index 1c9235a..6dfc981 100644
--- a/google_compute_engine/accounts/tests/accounts_daemon_test.py
+++ b/google_compute_engine/accounts/tests/accounts_daemon_test.py
@@ -16,10 +16,10 @@
"""Unittest for accounts_daemon.py module."""
import datetime
-import unittest
from google_compute_engine.accounts import accounts_daemon
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class AccountsDaemonTest(unittest.TestCase):
@@ -254,7 +254,7 @@ class AccountsDaemonTest(unittest.TestCase):
'invalid': '4',
'valid': '5',
}
- self.mock_setup.invalid_users = {'invalid'}
+ self.mock_setup.invalid_users = set(['invalid'])
# Make UpdateUser succeed for fake names longer than one character.
self.mock_utils.UpdateUser.side_effect = lambda user, _: len(user) > 1
accounts_daemon.AccountsDaemon._UpdateUsers(self.mock_setup, update_users)
@@ -268,11 +268,11 @@ class AccountsDaemonTest(unittest.TestCase):
self.assertEqual(
self.mock_utils.UpdateUser.call_count, len(expected_calls))
self.assertEqual(
- self.mock_setup.invalid_users, {'invalid', 'a', 'b', 'c'})
+ self.mock_setup.invalid_users, set(['invalid', 'a', 'b', 'c']))
def testRemoveUsers(self):
remove_users = ['a', 'b', 'c', 'valid']
- self.mock_setup.invalid_users = {'invalid', 'a', 'b', 'c'}
+ self.mock_setup.invalid_users = set(['invalid', 'a', 'b', 'c'])
accounts_daemon.AccountsDaemon._RemoveUsers(self.mock_setup, remove_users)
expected_calls = [
mock.call('a'),
@@ -281,7 +281,7 @@ class AccountsDaemonTest(unittest.TestCase):
mock.call('valid'),
]
self.mock_utils.RemoveUser.assert_has_calls(expected_calls)
- self.assertEqual(self.mock_setup.invalid_users, {'invalid'})
+ self.assertEqual(self.mock_setup.invalid_users, set(['invalid']))
def testHandleAccounts(self):
configured = ['c', 'c', 'b', 'b', 'a', 'a']
diff --git a/google_compute_engine/accounts/tests/accounts_utils_test.py b/google_compute_engine/accounts/tests/accounts_utils_test.py
index 28db01a..342d1c9 100644
--- a/google_compute_engine/accounts/tests/accounts_utils_test.py
+++ b/google_compute_engine/accounts/tests/accounts_utils_test.py
@@ -16,11 +16,11 @@
"""Unittest for accounts_utils.py module."""
import subprocess
-import unittest
from google_compute_engine.accounts import accounts_utils
from google_compute_engine.compat import builtin
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class AccountsUtilsTest(unittest.TestCase):
diff --git a/google_compute_engine/boto/compute_auth.py b/google_compute_engine/boto/compute_auth.py
index f8545a6..6956619 100644
--- a/google_compute_engine/boto/compute_auth.py
+++ b/google_compute_engine/boto/compute_auth.py
@@ -19,11 +19,11 @@ from boto import auth_handler
from google_compute_engine import logger
from google_compute_engine import metadata_watcher
-GS_SCOPES = {
+GS_SCOPES = set([
'https://www.googleapis.com/auth/devstorage.read_only',
'https://www.googleapis.com/auth/devstorage.read_write',
'https://www.googleapis.com/auth/devstorage.full_control',
-}
+])
class ComputeAuth(auth_handler.AuthHandler):
diff --git a/google_compute_engine/boto/tests/boto_config_test.py b/google_compute_engine/boto/tests/boto_config_test.py
index 8f570e9..3ce0157 100644
--- a/google_compute_engine/boto/tests/boto_config_test.py
+++ b/google_compute_engine/boto/tests/boto_config_test.py
@@ -15,10 +15,9 @@
"""Unittest for boto_config.py module."""
-import unittest
-
from google_compute_engine.boto import boto_config
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class BotoConfigTest(unittest.TestCase):
diff --git a/google_compute_engine/boto/tests/compute_auth_test.py b/google_compute_engine/boto/tests/compute_auth_test.py
index f30f934..63c39f6 100644
--- a/google_compute_engine/boto/tests/compute_auth_test.py
+++ b/google_compute_engine/boto/tests/compute_auth_test.py
@@ -15,10 +15,9 @@
"""Unittest for compute_auth.py module."""
-import unittest
-
from google_compute_engine.boto import compute_auth
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class ComputeAuthTest(unittest.TestCase):
diff --git a/google_compute_engine/clock_skew/tests/clock_skew_daemon_test.py b/google_compute_engine/clock_skew/tests/clock_skew_daemon_test.py
index 9330c57..8b0903e 100644
--- a/google_compute_engine/clock_skew/tests/clock_skew_daemon_test.py
+++ b/google_compute_engine/clock_skew/tests/clock_skew_daemon_test.py
@@ -16,10 +16,10 @@
"""Unittest for clock_skew_daemon.py module."""
import subprocess
-import unittest
from google_compute_engine.clock_skew import clock_skew_daemon
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class ClockSkewDaemonTest(unittest.TestCase):
diff --git a/google_compute_engine/compat.py b/google_compute_engine/compat.py
index 1bdd388..4b07532 100644
--- a/google_compute_engine/compat.py
+++ b/google_compute_engine/compat.py
@@ -40,4 +40,10 @@ if sys.version_info >= (3, 3):
else:
import mock
+# Import the unittest2 module to backport testing features to Python 2.6.
+if sys.version_info >= (2, 7):
+ import unittest
+else:
+ import unittest2 as unittest
+
builtin = 'builtins' if sys.version_info >= (3,) else '__builtin__'
diff --git a/google_compute_engine/instance_setup/tests/instance_setup_test.py b/google_compute_engine/instance_setup/tests/instance_setup_test.py
index d6a7e52..493d985 100644
--- a/google_compute_engine/instance_setup/tests/instance_setup_test.py
+++ b/google_compute_engine/instance_setup/tests/instance_setup_test.py
@@ -16,9 +16,9 @@
"""Unittest for instance_setup.py module."""
import subprocess
-import unittest
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.instance_setup import instance_setup
diff --git a/google_compute_engine/ip_forwarding/tests/ip_forwarding_daemon_test.py b/google_compute_engine/ip_forwarding/tests/ip_forwarding_daemon_test.py
index 30c8f32..49b4610 100644
--- a/google_compute_engine/ip_forwarding/tests/ip_forwarding_daemon_test.py
+++ b/google_compute_engine/ip_forwarding/tests/ip_forwarding_daemon_test.py
@@ -15,9 +15,8 @@
"""Unittest for ip_forwarding_daemon.py module."""
-import unittest
-
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.ip_forwarding import ip_forwarding_daemon
diff --git a/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py b/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
index 2b6cba9..26350e0 100644
--- a/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
+++ b/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
@@ -15,9 +15,8 @@
"""Unittest for ip_forwarding_utils.py module."""
-import unittest
-
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.ip_forwarding import ip_forwarding_utils
diff --git a/google_compute_engine/metadata_scripts/tests/script_executor_test.py b/google_compute_engine/metadata_scripts/tests/script_executor_test.py
index 259479d..15db71d 100644
--- a/google_compute_engine/metadata_scripts/tests/script_executor_test.py
+++ b/google_compute_engine/metadata_scripts/tests/script_executor_test.py
@@ -16,9 +16,9 @@
"""Unittest for script_executor.py module."""
import stat
-import unittest
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.metadata_scripts import script_executor
diff --git a/google_compute_engine/metadata_scripts/tests/script_manager_test.py b/google_compute_engine/metadata_scripts/tests/script_manager_test.py
index ca206d4..ec4970d 100644
--- a/google_compute_engine/metadata_scripts/tests/script_manager_test.py
+++ b/google_compute_engine/metadata_scripts/tests/script_manager_test.py
@@ -15,9 +15,8 @@
"""Unittest for script_manager.py module."""
-import unittest
-
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.metadata_scripts import script_manager
diff --git a/google_compute_engine/metadata_scripts/tests/script_retriever_test.py b/google_compute_engine/metadata_scripts/tests/script_retriever_test.py
index e9c4ae4..76ea05b 100644
--- a/google_compute_engine/metadata_scripts/tests/script_retriever_test.py
+++ b/google_compute_engine/metadata_scripts/tests/script_retriever_test.py
@@ -16,9 +16,9 @@
"""Unittest for script_retriever.py module."""
import subprocess
-import unittest
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
from google_compute_engine.metadata_scripts import script_retriever
@@ -125,7 +125,7 @@ class ScriptRetrieverTest(unittest.TestCase):
]
url_formats = [url % (bucket, obj) for url in url_formats]
if gs_match:
- gs_urls.update({url: gs_url for url in url_formats})
+ gs_urls.update(dict((url, gs_url) for url in url_formats))
return ([], gs_urls)
else:
return (url_formats, gs_urls)
diff --git a/google_compute_engine/tests/config_manager_test.py b/google_compute_engine/tests/config_manager_test.py
index 2afb721..fee7f9a 100644
--- a/google_compute_engine/tests/config_manager_test.py
+++ b/google_compute_engine/tests/config_manager_test.py
@@ -15,11 +15,10 @@
"""Unittest for config_manager.py module."""
-import unittest
-
from google_compute_engine import config_manager
from google_compute_engine.compat import builtin
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class ConfigManagerTest(unittest.TestCase):
diff --git a/google_compute_engine/tests/lock_file_test.py b/google_compute_engine/tests/lock_file_test.py
index ca5f5e7..4045629 100644
--- a/google_compute_engine/tests/lock_file_test.py
+++ b/google_compute_engine/tests/lock_file_test.py
@@ -15,10 +15,9 @@
"""Unittest for lock_file_test.py module."""
-import unittest
-
from google_compute_engine import lock_file
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class LockFileTest(unittest.TestCase):
diff --git a/google_compute_engine/tests/logger_test.py b/google_compute_engine/tests/logger_test.py
index c753780..3ffd803 100644
--- a/google_compute_engine/tests/logger_test.py
+++ b/google_compute_engine/tests/logger_test.py
@@ -15,10 +15,9 @@
"""Unittest for logger.py module."""
-import unittest
-
from google_compute_engine import logger
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class LoggerTest(unittest.TestCase):
diff --git a/google_compute_engine/tests/metadata_watcher_test.py b/google_compute_engine/tests/metadata_watcher_test.py
index 1cb398b..fee4146 100644
--- a/google_compute_engine/tests/metadata_watcher_test.py
+++ b/google_compute_engine/tests/metadata_watcher_test.py
@@ -16,10 +16,10 @@
"""Unittest for metadata_watcher.py module."""
import os
-import unittest
from google_compute_engine import metadata_watcher
from google_compute_engine.compat import mock
+from google_compute_engine.compat import unittest
class MetadataWatcherTest(unittest.TestCase):