Files
106eb47eff0551c73b2e90385b9c3a910fec8633
nova /run_tests.py

72 lines
2.3 KiB
Python
Raw Normal View History

2010年12月28日 01:40:24 -08:00
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# 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.
2011年01月12日 16:57:04 -08:00
import gettext
2010年12月28日 01:40:24 -08:00
import os
import unittest
import sys
from nose import config
from nose import result
from nose import core
class NovaTestResult(result.TextTestResult):
def __init__(self, *args, **kw):
result.TextTestResult.__init__(self, *args, **kw)
self._last_case = None
def getDescription(self, test):
return str(test)
def startTest(self, test):
unittest.TestResult.startTest(self, test)
current_case = test.test.__class__.__name__
if self.showAll:
if current_case != self._last_case:
self.stream.writeln(current_case)
self._last_case = current_case
self.stream.write(
'%s' % str(test.test._testMethodName).ljust(60))
self.stream.flush()
class NovaTestRunner(core.TextTestRunner):
def _makeResult(self):
return NovaTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config)
if __name__ == '__main__':
2011年02月20日 23:16:10 -08:00
if os.path.exists("nova.sqlite"):
os.unlink("nova.sqlite")
2010年12月28日 01:40:24 -08:00
c = config.Config(stream=sys.stdout,
env=os.environ,
plugins=core.DefaultPluginManager())
2010年12月28日 01:40:24 -08:00
runner = NovaTestRunner(stream=c.stream,
verbosity=c.verbosity,
config=c)
2010年12月30日 13:31:56 -08:00
sys.exit(not core.run(config=c, testRunner=runner))