Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: media/tools/layout_tests/test_expectations_history_unittest.py

Issue 7693018: Intial checkin of layout test analyzer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minor modifications. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import unittest
7 import time
8 from datetime import timedelta
9 from datetime import datetime
dennis_jeffrey 2011/08/25 00:36:46 Re-arrange the above 4 lines to put them in order
imasaki1 2011/08/25 23:57:03 Done.
10 from test_expectations_history import TestExpectationsHistory
11
12
13 class TestTestExpectaionsHistory(unittest.TestCase):
14 """A Unittest class for test_expectation_history module."""
dennis_jeffrey 2011/08/25 00:36:46 'Unit tests for the TestExpectationsHistory class.
imasaki1 2011/08/25 23:57:03 Done.
15
16 def AssertTestName(self, result_list, testname):
17 """Assert test name in the result_list
dennis_jeffrey 2011/08/25 00:36:46 add period at end of line
imasaki1 2011/08/25 23:57:03 Done.
18
19 This method is to chek the test name is in the result.
dennis_jeffrey 2011/08/25 00:36:46 I think this line is unnecessary; the first line o
imasaki1 2011/08/25 23:57:03 Done.
20 Args:
21 result_list: a result list of tuples returned by
22 |GetDiffBetweenTimesOnly1Diff()|. Each tuple consists of
23 (old_rev, new_rev, author, date, message, lines) where
24 |lines| are the entries in the test expectaton
dennis_jeffrey 2011/08/25 00:36:46 'expectaton' --> 'expectation'. Also add a period
imasaki1 2011/08/25 23:57:03 Done.
25 testname: a testname string.
26
27 Returns:
28 True if the result contains the testname.
dennis_jeffrey 2011/08/25 00:36:46 add this: ', and False otherwise.'
imasaki1 2011/08/25 23:57:03 Done.
29 """
30 for (old_rev, new_rev, author, date, message, lines) in result_list:
dennis_jeffrey 2011/08/25 00:36:46 We only actually need to use variable "lines", so
imasaki1 2011/08/25 23:57:03 Done.
31 for line in lines:
32 if testname in line:
33 return True
34 return False
dennis_jeffrey 2011/08/25 00:36:46 I think we can probably reduce this function down
imasaki1 2011/08/25 23:57:03 Done.
35
36 def testGetDiffBetweenTimes(self):
37 t = (2011, 8, 20, 0, 0, 0, 0, 0, 0)
38 ctime = time.mktime(t)
39 t = (2011, 8, 19, 0, 0, 0, 0, 0, 0)
40 ptime = time.mktime(t)
41 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
42 testname_list = (
43 [testname])
dennis_jeffrey 2011/08/25 00:36:46 Can fit on the previous line
imasaki1 2011/08/25 23:57:03 Done.
44 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
45 ctime, ptime, testname_list)
46 self.assertTrue(self.AssertTestName(result_list, testname))
47
48 def testGetDiffBetweenTimesOnly1Diff(self):
49 ptime = '2011-08-19-23'
50 ptime = datetime.strptime(ptime, "%Y-%m-%d-%H")
dennis_jeffrey 2011/08/25 00:36:46 Combine the above 2 lines into 1 line
imasaki1 2011/08/25 23:57:03 Done.
51 ptime = time.mktime(ptime.timetuple())
52 ctime = '2011-08-20-00'
53 ctime = datetime.strptime(ctime, "%Y-%m-%d-%H")
dennis_jeffrey 2011/08/25 00:36:46 Combine the above 2 lines into 1 line
imasaki1 2011/08/25 23:57:03 Done.
54 ctime = time.mktime(ctime.timetuple())
55 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
56 testname_list = (
57 [testname])
dennis_jeffrey 2011/08/25 00:36:46 can fit on the previous line
imasaki1 2011/08/25 23:57:03 Done.
58 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
59 ctime, ptime, testname_list)
60 self.assertTrue(self.AssertTestName(result_list, testname))
61
62
63 if __name__ == '__main__':
64 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698