Removing seconds unit

This commit is contained in:
Rick Harris 2011-06-15 00:08:19 +00:00
parent f46c9d7c96
commit 3368a35ff9
2 changed files with 9 additions and 17 deletions

View File

@ -185,20 +185,13 @@ class _NullColorizer(object):
self.stream.write(text)
def classify_test_speed(elapsed_time):
if elapsed_time > 1.0:
return 'slow'
elif elapsed_time > 0.25:
return 'sluggish'
else:
return 'fast'
def get_elapsed_time_color(elapsed_time):
color_map = {'slow': 'red', 'sluggish': 'yellow', 'fast': 'green'}
slowness = classify_test_speed(elapsed_time)
color = color_map[slowness]
return color
if elapsed_time > 1.0:
return 'red'
elif elapsed_time > 0.25:
return 'yellow'
else:
return 'green'
class NovaTestResult(result.TextTestResult):
@ -233,7 +226,6 @@ class NovaTestResult(result.TextTestResult):
def _writeElapsedTime(self, test):
color = get_elapsed_time_color(self.elapsed_time)
self.colorizer.write(" %.2f" % self.elapsed_time, color)
self.stream.write(' secs')
def _writeResult(self, test, long_result, color, short_result):
if self.showAll:
@ -322,13 +314,13 @@ class NovaTestRunner(core.TextTestRunner):
def _writeSlowTests(self, result_):
# Pare out 'fast' tests
slow_tests = [item for item in result_.slow_tests
if classify_test_speed(item[0]) != 'fast']
if get_elapsed_time_color(item[0]) != 'green']
slow_total_time = sum(item[0] for item in slow_tests)
self.stream.writeln("Slowest %i tests took %.2f secs:"
% (len(slow_tests), slow_total_time))
for elapsed_time, test in sorted(slow_tests, reverse=True):
time_str = "%.2f secs" % elapsed_time
time_str = "%.2f" % elapsed_time
self.stream.writeln(" %s %s" % (time_str.ljust(10), test))
def run(self, test):

View File

@ -10,7 +10,7 @@ function usage {
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -p, --pep8 Just run pep8"
echo " -h, --help Print this usage message"
echo " --show-elapsed Print elapsed time for tests along with slowest tests"
echo " --show-elapsed Print elapsed time in seconds for tests along with slowest tests"
echo ""
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "