~doanac/ubuntu-ci-services-itself/upgrade-support

« back to all changes in this revision

Viewing changes to bin/test_time_sorted_tests.py

  • Committer: Chris Johnston
  • Author(s): Evan Dandrea
  • Date: 2014-03-17 06:33:02 UTC
  • mfrom: (400.1.10 time-sorted-tests)
  • Revision ID: chris_johnston-20140317063302-52wct68d41e6qubs
[r=Andy Doan, Chris Johnston, PS Jenkins bot] Shave two minutes off test execution. Add a small program to print sorted test execution time.  from Evan Dandrea

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import time_sorted_tests
 
2
import unittest
 
3
import tempfile
 
4
import os
 
5
import sys
 
6
import mock
 
7
 
 
8
 
 
9
data = '''ticket.tests.test_read_api.TicketReadAPITest.test_get_ticket_steps_detail ...  OK (0.049 secs)
 
10
ticket.tests.test_read_api.TicketReadAPITest.test_get_ticket_update_status_api ... OK (0.046 secs)'''
 
11
 
 
12
 
 
13
class T(unittest.TestCase):
 
14
    def test_gen_timings(self):
 
15
        t = time_sorted_tests.gen_timings(data)
 
16
        t = t.next()
 
17
        self.assertEqual(t[0], 'ticket.tests.test_read_api.TicketReadAPITest.test_get_ticket_steps_detail')
 
18
        self.assertEqual(t[1], 0.049)
 
19
 
 
20
    def test_gen_timings_bad_data(self):
 
21
        t = time_sorted_tests.gen_timings(data + '\noutput from test.')
 
22
        # Iterate through all the data.
 
23
        [x for x in t]
 
24
 
 
25
    def test_sort_timings(self):
 
26
        t = time_sorted_tests.gen_timings(data)
 
27
        s = time_sorted_tests.sort_timings(t)
 
28
        self.assertEqual(s[0][1], 0.046)
 
29
        self.assertEqual(s[1][1], 0.049)
 
30
 
 
31
if __name__ == '__main__':
 
32
    unittest.main()