Skip to content
Newer
Older
100644 74 lines (58 sloc) 2.27 KB
7e46969 Output of run_tests.sh to be closer to trial
termie authored Dec 28, 2010
1 #!/usr/bin/env python
2 # vim: tabstop=4 shiftwidth=4 softtabstop=4
3
4 # Copyright 2010 United States Government as represented by the
5 # Administrator of the National Aeronautics and Space Administration.
6 # All Rights Reserved.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19
4f5c0c6 add support for database migration
Andy Smith authored Jan 12, 2011
20 import gettext
7e46969 Output of run_tests.sh to be closer to trial
termie authored Dec 28, 2010
21 import os
22 import unittest
23 import sys
24
25 from nose import config
26 from nose import result
27 from nose import core
28
29644fe @vishvananda switch to explicit call to logging.setup()
vishvananda authored Feb 21, 2011
29 from nova import log as logging
11c5786 @vishvananda fixed newline and moved import fake_flags into run_tests where it mak…
vishvananda authored Feb 21, 2011
30 from nova.tests import fake_flags
31
7e46969 Output of run_tests.sh to be closer to trial
termie authored Dec 28, 2010
32
33 class NovaTestResult(result.TextTestResult):
34 def __init__(self, *args, **kw):
35 result.TextTestResult.__init__(self, *args, **kw)
36 self._last_case = None
37
38 def getDescription(self, test):
39 return str(test)
40
41 def startTest(self, test):
42 unittest.TestResult.startTest(self, test)
43 current_case = test.test.__class__.__name__
44
45 if self.showAll:
46 if current_case != self._last_case:
47 self.stream.writeln(current_case)
48 self._last_case = current_case
49
50 self.stream.write(
51 ' %s' % str(test.test._testMethodName).ljust(60))
52 self.stream.flush()
53
54
55 class NovaTestRunner(core.TextTestRunner):
56 def _makeResult(self):
57 return NovaTestResult(self.stream,
58 self.descriptions,
59 self.verbosity,
60 self.config)
61
62
63 if __name__ == '__main__':
29644fe @vishvananda switch to explicit call to logging.setup()
vishvananda authored Feb 21, 2011
64 logging.setup()
7e46969 Output of run_tests.sh to be closer to trial
termie authored Dec 28, 2010
65 c = config.Config(stream=sys.stdout,
66 env=os.environ,
b2ec5bf @sorenh Pass a PluginManager to nose.config.Config(). This lets us use plugin…
sorenh authored Jan 20, 2011
67 verbosity=3,
68 plugins=core.DefaultPluginManager())
7e46969 Output of run_tests.sh to be closer to trial
termie authored Dec 28, 2010
69
70 runner = NovaTestRunner(stream=c.stream,
71 verbosity=c.verbosity,
72 config=c)
384da35 change exit code
termie authored Dec 30, 2010
73 sys.exit(not core.run(config=c, testRunner=runner))
Something went wrong with that request. Please try again.