Merge "Remove unused variables"
diff --git a/run_tests.sh b/run_tests.sh
index 93edfaf..3f394e3 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -95,14 +95,7 @@
 
 function run_pep8 {
   echo "Running pep8 ..."
-  srcfiles="`find tempest -type f -name "*.py"`"
-  srcfiles+=" `find tools -type f -name "*.py"`"
-  srcfiles+=" `find stress -type f -name "*.py"`"
-  srcfiles+=" setup.py"
-
-  ignore='--ignore=E121,E122,E125,E126'
-
-    ${wrapper} python tools/hacking.py ${ignore} ${srcfiles}
+  ${wrapper} tools/check_source.sh
 }
 
 function run_coverage_start {
diff --git a/tempest/tests/compute/servers/test_list_servers_negative.py b/tempest/tests/compute/servers/test_list_servers_negative.py
index 01b11e0..0559206 100644
--- a/tempest/tests/compute/servers/test_list_servers_negative.py
+++ b/tempest/tests/compute/servers/test_list_servers_negative.py
@@ -22,12 +22,12 @@
 from tempest.tests.compute import base
 
 
-class ListServersNegativeTest(base.BaseComputeTest):
+class ListServersNegativeTestJSON(base.BaseComputeTest):
     _interface = 'json'
 
     @classmethod
     def setUpClass(cls):
-        super(ListServersNegativeTest, cls).setUpClass()
+        super(ListServersNegativeTestJSON, cls).setUpClass()
         cls.client = cls.servers_client
         cls.servers = []
 
@@ -138,7 +138,8 @@
         # List servers by specifying limits
         resp, body = self.client.list_servers({'limit': 1})
         self.assertEqual('200', resp['status'])
-        self.assertEqual(1, len(body['servers']))
+        #when _interface='xml', one element for servers_links in servers
+        self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
 
     def test_list_servers_by_limits_greater_than_actual_count(self):
         # List servers by specifying a greater value for limit
@@ -187,3 +188,7 @@
                   if srv['id'] in deleted_ids]
         self.assertEqual('200', resp['status'])
         self.assertEqual([], actual)
+
+
+class ListServersNegativeTestXML(ListServersNegativeTestJSON):
+    _interface = 'xml'
diff --git a/tempest/tests/network/test_network_basic_ops.py b/tempest/tests/network/test_network_basic_ops.py
index 7d0ded3..a38a5c0 100644
--- a/tempest/tests/network/test_network_basic_ops.py
+++ b/tempest/tests/network/test_network_basic_ops.py
@@ -16,9 +16,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common import exceptions as exc
 from tempest.common.utils.data_utils import rand_name
-from tempest import test
 from tempest.tests.network.common import DeletableRouter
 from tempest.tests.network.common import TestNetworkSmokeCommon
 
diff --git a/tools/check_source.sh b/tools/check_source.sh
new file mode 100755
index 0000000..089ad70
--- /dev/null
+++ b/tools/check_source.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+python tools/hacking.py --ignore=E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack,*egg .
+pep8_ret=$?
+
+pyflakes tempest stress setup.py tools cli bin | grep "imported but unused"
+unused_ret=$?
+
+ret=0
+if [ $pep8_ret != 0 ]; then
+    echo "hacking.py/pep8 test FAILED!" >&2
+    (( ret += 1  ))
+else
+    echo "hacking.py/pep8 test OK!" >&2
+fi
+
+if [ $unused_ret == 0 ]; then
+    echo "Unused import test FAILED!" >&2
+    (( ret += 2  ))
+else
+    echo "Unused import test OK!" >&2
+fi
+
+exit $ret
diff --git a/tools/test-requires b/tools/test-requires
index b799dce..f701dab 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -2,3 +2,4 @@
 pylint==0.19
 #TODO(afazekas): ensure pg_config installed
 psycopg2
+pyflakes
diff --git a/tox.ini b/tox.ini
index 92ce6bc..85a0d86 100644
--- a/tox.ini
+++ b/tox.ini
@@ -19,4 +19,4 @@
            python -m tools/tempest_coverage -c report --html
 
 [testenv:pep8]
-commands = python tools/hacking.py --ignore=E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack,*egg .
+commands = bash tools/check_source.sh