summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-07-02 08:48:28 -0400
committerMonty Taylor <mordred@inaugust.com>2012-07-02 08:50:41 -0400
commit8d8d3b4296bf37f10c9b0faa0e86ebfdc8b05862 (patch)
treec1565380c10d99506ad29d8d1fc62e1ec388aa91
parent019d953ef5b4bed7c53401375bfd7aa890fc0c1d (diff)
Run hacking tests as part of the gate.
Nova has additional pep8 "plugins" that they expect to run as part of the gate. This patch will run tools/hacking.py instead of pep8 directly. Also, it fixes the hacking violaions in contrib, plugins and smoketests. Fixes bug 1010136 Change-Id: I86d8789218c197d5d4a43d1201465d340646a395
-rw-r--r--contrib/boto_v6/ec2/connection.py4
-rw-r--r--contrib/boto_v6/ec2/instance.py4
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py1
-rw-r--r--smoketests/base.py6
-rw-r--r--smoketests/public_network_smoketests.py2
-rw-r--r--smoketests/run_tests.py14
-rw-r--r--smoketests/test_netadmin.py2
-rw-r--r--smoketests/test_sysadmin.py6
-rw-r--r--tox.ini2
9 files changed, 23 insertions, 18 deletions
diff --git a/contrib/boto_v6/ec2/connection.py b/contrib/boto_v6/ec2/connection.py
index a0cfd7e26..940608ffd 100644
--- a/contrib/boto_v6/ec2/connection.py
+++ b/contrib/boto_v6/ec2/connection.py
@@ -3,11 +3,11 @@ Created on 2010/12/20
@author: Nachi Ueno <ueno.nachi@lab.ntt.co.jp>
'''
-import boto
import base64
+import boto
import boto.ec2
-from boto_v6.ec2.instance import ReservationV6
from boto.ec2.securitygroup import SecurityGroup
+from boto_v6.ec2.instance import ReservationV6
class EC2ConnectionV6(boto.ec2.EC2Connection):
diff --git a/contrib/boto_v6/ec2/instance.py b/contrib/boto_v6/ec2/instance.py
index 9208c05ad..74adccc00 100644
--- a/contrib/boto_v6/ec2/instance.py
+++ b/contrib/boto_v6/ec2/instance.py
@@ -3,10 +3,10 @@ Created on 2010/12/20
@author: Nachi Ueno <ueno.nachi@lab.ntt.co.jp>
'''
-from boto.resultset import ResultSet
-from boto.ec2.instance import Reservation
from boto.ec2.instance import Group
from boto.ec2.instance import Instance
+from boto.ec2.instance import Reservation
+from boto.resultset import ResultSet
class ReservationV6(Reservation):
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
index 7e27b4ff7..5cfd32dbd 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
@@ -26,6 +26,7 @@ try:
import json
except ImportError:
import simplejson as json
+
import logging
import os
import subprocess
diff --git a/smoketests/base.py b/smoketests/base.py
index db28b6f5a..aa0a0aae2 100644
--- a/smoketests/base.py
+++ b/smoketests/base.py
@@ -17,6 +17,7 @@
# under the License.
import boto
+from boto.ec2.regioninfo import RegionInfo
import commands
import httplib
import os
@@ -24,7 +25,6 @@ import paramiko
import sys
import time
import unittest
-from boto.ec2.regioninfo import RegionInfo
from smoketests import flags
@@ -150,7 +150,7 @@ class SmokeTestCase(unittest.TestCase):
def create_key_pair(self, conn, key_name):
try:
os.remove('/tmp/%s.pem' % key_name)
- except:
+ except Exception:
pass
key = conn.create_key_pair(key_name)
key.save('/tmp/')
@@ -160,7 +160,7 @@ class SmokeTestCase(unittest.TestCase):
conn.delete_key_pair(key_name)
try:
os.remove('/tmp/%s.pem' % key_name)
- except:
+ except Exception:
pass
def bundle_image(self, image, tempdir='/tmp', kernel=False):
diff --git a/smoketests/public_network_smoketests.py b/smoketests/public_network_smoketests.py
index 5e1d7aaa9..4fb843e0f 100644
--- a/smoketests/public_network_smoketests.py
+++ b/smoketests/public_network_smoketests.py
@@ -30,8 +30,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from smoketests import flags
from smoketests import base
+from smoketests import flags
#Note that this test should run from
#public network (outside of private network segments)
diff --git a/smoketests/run_tests.py b/smoketests/run_tests.py
index 30592b6a3..053acc09f 100644
--- a/smoketests/run_tests.py
+++ b/smoketests/run_tests.py
@@ -57,8 +57,8 @@ To run a single test module:
import gettext
import os
-import unittest
import sys
+import unittest
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -110,7 +110,7 @@ class _AnsiColorizer(object):
except curses.error:
curses.setupterm()
return curses.tigetnum("colors") > 2
- except:
+ except Exception:
raise
# guess false in case of error
return False
@@ -133,9 +133,13 @@ class _Win32Colorizer(object):
See _AnsiColorizer docstring.
"""
def __init__(self, stream):
- from win32console import (GetStdHandle, STD_OUT_HANDLE,
- FOREGROUND_RED, FOREGROUND_GREEN,
- FOREGROUND_BLUE, FOREGROUND_INTENSITY)
+ from win32console import FOREGROUND_BLUE
+ from win32console import FOREGROUND_GREEN
+ from win32console import FOREGROUND_INTENSITY
+ from win32console import FOREGROUND_RED
+ from win32console import GetStdHandle
+ from win32console import STD_OUT_HANDLE
+
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
self.stream = stream
diff --git a/smoketests/test_netadmin.py b/smoketests/test_netadmin.py
index 6a0dc48ec..4215f705d 100644
--- a/smoketests/test_netadmin.py
+++ b/smoketests/test_netadmin.py
@@ -30,8 +30,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from smoketests import flags
from smoketests import base
+from smoketests import flags
FLAGS = flags.FLAGS
diff --git a/smoketests/test_sysadmin.py b/smoketests/test_sysadmin.py
index 5e599d15b..8414a755f 100644
--- a/smoketests/test_sysadmin.py
+++ b/smoketests/test_sysadmin.py
@@ -18,10 +18,10 @@
import os
import random
+import shutil
import sys
-import time
import tempfile
-import shutil
+import time
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -31,8 +31,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from smoketests import flags
from smoketests import base
+from smoketests import flags
FLAGS = flags.FLAGS
flags.DEFINE_string('bundle_kernel', 'random.kernel',
diff --git a/tox.ini b/tox.ini
index 08aa9686a..4e1864d77 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,7 +18,7 @@ downloadcache = ~/cache/pip
[testenv:pep8]
deps = pep8==1.1
-commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,*egg .
+commands = python tools/hacking.py --ignore=N4 --repeat --show-source --exclude=.venv,.tox,dist,doc,*egg .
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1