blob: 157fc5fc6d58eb6e978190f2b259a4c6c815516b [file] [log] [blame]
Matthew Treinish519cb3e2013-10-28 20:27:38 +00001# Copyright 2013 IBM Corp.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import re
16import subprocess
17
18from tempest.tests import base
19
20
21class TestTestList(base.TestCase):
22
23 def test_no_import_errors(self):
24 import_failures = []
25 p = subprocess.Popen(['testr', 'list-tests'], stdout=subprocess.PIPE)
26 ids = p.stdout.read()
27 ids = ids.split('\n')
28 for test_id in ids:
29 if re.match('(\w+\.){3}\w+', test_id):
30 if not test_id.startswith('tempest.'):
31 fail_id = test_id.split('unittest.loader.ModuleImport'
32 'Failure.')[1]
33 import_failures.append(fail_id)
34 error_message = ("The following tests have import failures and aren't"
35 " being run with test filters %s" % import_failures)
36 self.assertFalse(import_failures, error_message)