Add tempest unit test to verify the test list
If there is an error in a test file it could potentially not get run in the tox jobs used for gating. This commit adds a test which looks for ImportFailures in the test list to ensure that all the test files will get run in the gate. Change-Id: Ia0a5831810d04f2201bd856039362b4a30f39319
This commit is contained in:
parent
f054a9c5f1
commit
519cb3ebf5
38
tempest/tests/test_list_tests.py
Normal file
38
tempest/tests/test_list_tests.py
Normal file
@ -0,0 +1,38 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from tempest.tests import base
|
||||
|
||||
|
||||
class TestTestList(base.TestCase):
|
||||
|
||||
def test_no_import_errors(self):
|
||||
import_failures = []
|
||||
p = subprocess.Popen(['testr', 'list-tests'], stdout=subprocess.PIPE)
|
||||
ids = p.stdout.read()
|
||||
ids = ids.split('\n')
|
||||
for test_id in ids:
|
||||
if re.match('(\w+\.){3}\w+', test_id):
|
||||
if not test_id.startswith('tempest.'):
|
||||
fail_id = test_id.split('unittest.loader.ModuleImport'
|
||||
'Failure.')[1]
|
||||
import_failures.append(fail_id)
|
||||
error_message = ("The following tests have import failures and aren't"
|
||||
" being run with test filters %s" % import_failures)
|
||||
self.assertFalse(import_failures, error_message)
|
Loading…
x
Reference in New Issue
Block a user