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